Skip to content

Commit 47cb236

Browse files
authored
fix: Login was successful even it is not authenticated (#2322)
* fix: the login were successful even if values of PostAuthResponse were null * remove unnecessary part
1 parent 1bc8f49 commit 47cb236

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package com.mifos.feature.auth.login
1111

1212
import android.content.Context
13-
import android.util.Log
1413
import androidx.lifecycle.ViewModel
1514
import androidx.lifecycle.viewModelScope
1615
import com.mifos.core.common.utils.Network
@@ -88,9 +87,8 @@ class LoginViewModel @Inject constructor(
8887
}
8988

9089
is Resource.Success -> {
91-
result.data?.let {
92-
Log.d("Android", "$it")
93-
prefManager.saveUserDetails(it)
90+
if (result.data?.authenticated == true) {
91+
prefManager.saveUserDetails(result.data!!)
9492
// Saving username password
9593
prefManager.usernamePassword = Pair(username, password)
9694
// Updating Services
@@ -102,6 +100,9 @@ class LoginViewModel @Inject constructor(
102100
secured = true,
103101
)
104102
_loginUiState.value = LoginUiState.Success
103+
} else {
104+
_loginUiState.value =
105+
ShowError(R.string.feature_auth_error_login_failed)
105106
}
106107
}
107108
}

0 commit comments

Comments
 (0)