Skip to content
Snippets Groups Projects
Commit d5934925 authored by Altair1618's avatar Altair1618
Browse files

fix: put sharedpref when auto login

parent aca597a8
Branches
Tags
1 merge request!46Dev
...@@ -13,12 +13,10 @@ import kotlinx.coroutines.launch ...@@ -13,12 +13,10 @@ import kotlinx.coroutines.launch
class LoginViewModel : ViewModel() { class LoginViewModel : ViewModel() {
private val _loginResponse = MutableLiveData<LoginResponse?>() private val _loginResponse = MutableLiveData<LoginResponse?>()
val loginResponse: LiveData<LoginResponse?> val loginResponse: LiveData<LoginResponse?> = _loginResponse
get() = _loginResponse
private val _tokenResponse = MutableLiveData<TokenResponse?>() private val _tokenResponse = MutableLiveData<TokenResponse?>()
val tokenResponse: LiveData<TokenResponse?> val tokenResponse: LiveData<TokenResponse?> = _tokenResponse
get() = _tokenResponse
fun login( fun login(
email: String, email: String,
......
...@@ -145,6 +145,19 @@ class LoginActivity : AppCompatActivity() { ...@@ -145,6 +145,19 @@ class LoginActivity : AppCompatActivity() {
return@Observer return@Observer
} }
val nim: String = response.nim!!
PreferencesManager.putString(this, "token", token, true)
PreferencesManager.putString(this, "nim", nim, true)
PreferencesManager.putString(this, "email", "${nim}@std.stei.itb.ac.id", true)
// Start ExpiryService
val serviceIntent = Intent(this, ExpiryService::class.java).apply {
putExtra("timeout", expiryDuration)
}
stopService(serviceIntent)
startService(serviceIntent)
val intent = Intent(this, MainActivity::class.java) val intent = Intent(this, MainActivity::class.java)
startActivity(intent) startActivity(intent)
finish() finish()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment