diff options
author | Zsika Phillip <protocol86@users.noreply.github.com> | 2018-04-12 16:54:22 -0700 |
---|---|---|
committer | Paul Beusterien <paulbeusterien@google.com> | 2018-04-12 16:57:55 -0700 |
commit | c875e432836de36483e2dca9a8a85bfd90bc6f52 (patch) | |
tree | f8a9036044f18291ef41f34cef65c018c904f2b8 /Firebase | |
parent | e29010caf2478c7b6d4cbb4a3fe8238f36b4fe22 (diff) |
Fixes typo that causes token parsing to break (#1076)
Diffstat (limited to 'Firebase')
-rw-r--r-- | Firebase/Auth/Source/FIRUser.m | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m index 1b10976..0a0a664 100644 --- a/Firebase/Auth/Source/FIRUser.m +++ b/Firebase/Auth/Source/FIRUser.m @@ -836,23 +836,29 @@ static void callInMainThreadWithAuthDataResultAndError( NSMutableString *tokenPayload = [[NSMutableString alloc] initWithString:tokenStringArray[1]]; // Pad the token payload with "=" signs if the payload's length is not a multple of 4. - int remainder = tokenPayload.length % 4 != 0; - if (remainder) { - while (remainder --) { - [tokenPayload appendString:@"="]; - } + while ((tokenPayload.length % 4) != 0) { + [tokenPayload appendFormat:@"="]; } NSData *decodedTokenPayloadData = [[NSData alloc] initWithBase64EncodedString:tokenPayload options:NSDataBase64DecodingIgnoreUnknownCharacters]; + if (!decodedTokenPayloadData) { + *error = [FIRAuthErrorUtils unexpectedResponseWithDeserializedResponse:token]; + return nil; + } NSDictionary *tokenPayloadDictionary = [NSJSONSerialization JSONObjectWithData:decodedTokenPayloadData - options:kNilOptions + options:NSJSONReadingMutableContainers|NSJSONReadingAllowFragments error:error]; if (error) { return nil; } + if (!tokenPayloadDictionary) { + *error = [FIRAuthErrorUtils unexpectedResponseWithDeserializedResponse:token]; + return nil; + } + NSDate *expDate = [NSDate dateWithTimeIntervalSinceNow:[tokenPayloadDictionary[@"exp"] doubleValue]]; NSDate *authDate = |