-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Avoiding signing out users when the token refresh fails due to n…
…o connectivity (#104)
- Loading branch information
Showing
4 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
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
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