Skip to content

Commit

Permalink
fix(auth): Crash in getToken api (aws-amplify#4290)
Browse files Browse the repository at this point in the history
  • Loading branch information
royjit authored and samkudr committed Sep 26, 2022
1 parent 7f94a29 commit f63c967
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Expand Up @@ -34,15 +34,19 @@ extension AWSMobileClient {
AWSMobileClientLogging.verbose("Adding FetchUserPoolTokensOperation operation")
let operation = FetchUserPoolTokensOperation(completion: completionHandler)
operation.delegate = self
tokenOperations.add(operation)
tokenFetchOperationQueue.addOperation {
self.tokenOperations.add(operation)
}
tokenFetchOperationQueue.addOperation(operation)
case .hostedUI:
AWSMobileClientLogging.verbose("Invoking hostedUI getTokens")
let operation = FetchUserPoolTokensOperation(
userPool: AWSCognitoAuth(forKey: AWSMobileClientConstants.CognitoAuthRegistrationKey),
completion: completionHandler)
operation.delegate = self
tokenOperations.add(operation)
tokenFetchOperationQueue.addOperation {
self.tokenOperations.add(operation)
}
tokenFetchOperationQueue.addOperation(operation)
default:
let message = AWSMobileClientConstants.notSignedInMessage
Expand Down
Expand Up @@ -55,12 +55,12 @@ + (NSString *) userContextString:(int) minTarget
CGRect bounds = [[UIScreen mainScreen] nativeBounds];
CGFloat screenWidth = bounds.size.width;
CGFloat screenHeight = bounds.size.height;

NSDateFormatter *localTimeZoneFormatter = [NSDateFormatter new];
localTimeZoneFormatter.timeZone = [NSTimeZone localTimeZone];
localTimeZoneFormatter.dateFormat = @"Z";
NSString *localTimeZoneOffset = [localTimeZoneFormatter stringFromDate:[NSDate date]];

NSString *hourOffset = [localTimeZoneOffset substringToIndex:[localTimeZoneOffset length] - 2];
NSString *minuteOffset = [localTimeZoneOffset substringFromIndex:[localTimeZoneOffset length] - 2];
NSString *timezoneOffset = [NSString stringWithFormat:@"%@:%@",hourOffset,minuteOffset];
Expand Down

0 comments on commit f63c967

Please sign in to comment.