|
|
|
@ -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 ->
|
|
|
|
|
authStateManager
|
|
|
|
|
.current
|
|
|
|
|
.performActionWithFreshTokens(authorizationService) { _, idToken, exception ->
|
|
|
|
|
authState.performActionWithFreshTokens(authorizationService) { _, idToken, exception ->
|
|
|
|
|
if (exception == null) {
|
|
|
|
|
cont.resumeWith(Result.success(idToken))
|
|
|
|
|
} else {
|
|
|
|
@ -77,8 +80,5 @@ class AuthorizationService @Inject constructor(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun signOut() {
|
|
|
|
|
authStateManager.signOut()
|
|
|
|
|
}
|
|
|
|
|
}
|