Update api login information with user input

This commit is contained in:
davide 2022-07-25 15:20:36 +02:00
parent da4bdd2355
commit b14b34441b
4 changed files with 14 additions and 11 deletions

View File

@ -203,13 +203,7 @@ class LoginActivity() : AppCompatActivity(), DIAware {
} else { } else {
showProgress(true) showProgress(true)
settings.putString("url", url) repository.refreshLoginInformation(url, login, password, httpLogin, httpPassword, isWithSelfSignedCert)
settings.putString("login", login)
settings.putString("httpUserName", httpLogin)
settings.putString("password", password)
settings.putString("httpPassword", httpPassword)
settings.putBoolean("isSelfSignedCert", isWithSelfSignedCert)
repository.refreshLoginInformation()
if (this@LoginActivity.isNetworkAvailable(this@LoginActivity.findViewById(R.id.loginForm))) { if (this@LoginActivity.isNetworkAvailable(this@LoginActivity.findViewById(R.id.loginForm))) {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {

View File

@ -35,5 +35,7 @@ interface Repository {
suspend fun deleteSource(id: Int): Boolean suspend fun deleteSource(id: Int): Boolean
suspend fun updateRemote(): Boolean suspend fun updateRemote(): Boolean
suspend fun login(): Boolean suspend fun login(): Boolean
fun refreshLoginInformation() fun refreshLoginInformation(url: String, login: String, password: String,
httpLogin: String, httpPassword: String,
isSelfSignedCert: Boolean)
} }

View File

@ -275,9 +275,17 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
return result return result
} }
override fun refreshLoginInformation() { override fun refreshLoginInformation(url: String, login: String, password: String,
httpLogin: String, httpPassword: String,
isSelfSignedCert: Boolean) {
settings.putString("url", url)
settings.putString("login", login)
settings.putString("httpUserName", httpLogin)
settings.putString("password", password)
settings.putString("httpPassword", httpPassword)
settings.putBoolean("isSelfSignedCert", isSelfSignedCert)
baseUrl = url
api.refreshLoginInformation() api.refreshLoginInformation()
baseUrl = apiDetails.getBaseUrl()
} }
private suspend fun updateApiVersion() { private suspend fun updateApiVersion() {

View File

@ -47,7 +47,6 @@ class ApiDetailsServiceImpl : ApiDetailsService {
_password = settings.getString("password", "") _password = settings.getString("password", "")
_userName = settings.getString("login", "") _userName = settings.getString("login", "")
_baseUrl = settings.getString("url", "") _baseUrl = settings.getString("url", "")
_baseUrl = settings.getString("url", "")
_apiVersion = settings.getInt("apiVersionMajor", -1) _apiVersion = settings.getInt("apiVersionMajor", -1)
} }
} }