refactor: Don't request a new access token unless needed
This commit is contained in:
parent
a4890a1bb3
commit
8f20cabb33
|
@ -57,9 +57,12 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private suspend fun checkUserLogin(): Boolean {
|
||||
if (authRepository.validateRefreshToken() != null) {
|
||||
// Get a brand new access token (even if the old access token is still valid,
|
||||
// it's better to just get a new one so it doesn't expire as quickly on us)
|
||||
return authRepository.refreshAccessToken()
|
||||
if (authRepository.validateAccessToken() == null) {
|
||||
// In case access token is already invalid, request a new one
|
||||
return authRepository.refreshAccessToken()
|
||||
}
|
||||
// Access token still valid, we're already logged in
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue