-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Avoid signing out users when the token refresh failed due to con…
…nectivity issues on startup
- Loading branch information
Showing
3 changed files
with
34 additions
and
17 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
Sources/Authenticator/Extensions/AuthError+Connectivity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Amplify | ||
import Foundation | ||
|
||
extension AuthError { | ||
var isConnectivityError: Bool { | ||
guard let error = underlyingError as? NSError else { | ||
return false | ||
} | ||
|
||
let networkErrorCodes = [ | ||
NSURLErrorCannotFindHost, | ||
NSURLErrorCannotConnectToHost, | ||
NSURLErrorNetworkConnectionLost, | ||
NSURLErrorDNSLookupFailed, | ||
NSURLErrorNotConnectedToInternet | ||
] | ||
return networkErrorCodes.contains(where: { $0 == error.code }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters