Skip to content

Commit

Permalink
Fixed logout loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mickmaccallum committed Dec 2, 2024
1 parent e567bfa commit 72943ed
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions ios/Sources/Parra/Networking/Servers/Auth/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,30 @@ final class AuthService {
// The actual cached token.
private var _cachedCredential: ParraUser.Credential?

/// Only for use when the refresh token has expired! Dumps local user
/// and triggers reauthentication flow.
private func forceLogout() async throws {
await applyUserUpdate(.undetermined, shouldBroadcast: true)

let appInfo = try await Parra.default.parraInternal.appInfoManager.getAppInfo()

let result: ParraAuthState
do {
result = try await performUnauthenticatedLogin(
appInfo: appInfo
)
} catch {
printInvalidAuth(error: error)

throw error
}

await applyUserUpdate(
result,
shouldBroadcast: true
)
}

private func performUnauthenticatedLogin(
appInfo: ParraAppInfo
) async throws -> ParraAuthState {
Expand Down Expand Up @@ -606,7 +630,7 @@ final class AuthService {
error
)

await logout()
try await forceLogout()

return nil
}
Expand All @@ -620,7 +644,7 @@ final class AuthService {
error
)

await logout()
try await forceLogout()

return nil
}
Expand Down

0 comments on commit 72943ed

Please sign in to comment.