Failure when finding a refresh token in a non OIDC login (#2377)

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
Mauro 2024-01-25 13:35:26 +01:00 committed by GitHub
parent a9460cc06f
commit 99a31cab00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 1 deletions

View File

@ -186,6 +186,10 @@ final class SoftLogoutScreenCoordinator: CoordinatorProtocol {
case .oidcError(.userCancellation):
// No need to show an error, the user cancelled authentication.
break
case .sessionTokenRefreshNotSupported:
// We should display a specific error saying that we do not support this kind of login
// But the copy is TBD
viewModel.displayError(.alert(L10n.errorUnknown))
default:
viewModel.displayError(.alert(L10n.errorUnknown))
}

View File

@ -122,6 +122,18 @@ class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
deviceId: deviceID)
}
let refreshToken = try? await Task.dispatch(on: .global()) {
try client.session().refreshToken
}
if refreshToken != nil {
MXLog.warning("Refresh token found for a non oidc session, can't restore session, logging out")
_ = await Task.dispatch(on: .global()) {
try? client.logout()
}
return .failure(.sessionTokenRefreshNotSupported)
}
return await userSession(for: client)
} catch {
MXLog.error("Failed logging in with error: \(error)")

View File

@ -34,8 +34,8 @@ enum AuthenticationServiceError: Error {
case slidingSyncNotAvailable
case accountDeactivated
case failedLoggingIn
case isOnWaitlist
case sessionTokenRefreshNotSupported
}
protocol AuthenticationServiceProxyProtocol {

1
changelog.d/2365.bugfix Normal file
View File

@ -0,0 +1 @@
If a refresh token is found in a non OIDC session, the app will be logged out.