Don't try to get fresh token if not authorized

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

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