Don't try to get fresh token if not authorized

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

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