Don't try to get fresh token if not authorized

pull/1231/head
Alex Baker 4 years ago
parent 26b2f9d346
commit 8044a70f38

@ -64,11 +64,14 @@ class AuthorizationService @Inject constructor(
} }
} }
suspend fun getFreshToken(): String? = withContext(Dispatchers.IO) { suspend fun getFreshToken(): String? {
val authState = authStateManager.current
if (!authState.isAuthorized) {
return null
}
return withContext(Dispatchers.IO) {
suspendCoroutine { cont -> suspendCoroutine { cont ->
authStateManager authState.performActionWithFreshTokens(authorizationService) { _, idToken, exception ->
.current
.performActionWithFreshTokens(authorizationService) { _, idToken, exception ->
if (exception == null) { if (exception == null) {
cont.resumeWith(Result.success(idToken)) cont.resumeWith(Result.success(idToken))
} else { } else {
@ -77,8 +80,5 @@ class AuthorizationService @Inject constructor(
} }
} }
} }
fun signOut() {
authStateManager.signOut()
} }
} }
Loading…
Cancel
Save