Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 281
Add Three token properties in GIDGoogleUser API#189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
549213e85206371f540004094422be4f6fa71f82c002d3736b320b07611112659886e4be0b965d86d5a9bedf7f65b7b0dec70498c8b9d15b288671ba54bf30File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,13 +22,15 @@ | ||
| static NSString *const kTokenStringKey = @"tokenString"; | ||
| static NSString *const kExpirationDateKey = @"expirationDate"; | ||
| NS_ASSUME_NONNULL_BEGIN | ||
| @implementation GIDToken | ||
Alex-4-Git marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| - (instancetype)initWithTokenString:(NSString *)tokenString | ||
| expirationDate:(NSDate *)expirationDate { | ||
| expirationDate:(nullable NSDate *)expirationDate { | ||
| self = [super init]; | ||
| if (self) { | ||
| _tokenString = tokenString; | ||
| _tokenString = [tokenString copy]; | ||
| _expirationDate = expirationDate; | ||
| } | ||
| @@ -55,4 +57,40 @@ - (void)encodeWithCoder:(NSCoder *)encoder { | ||
| [encoder encodeObject:_expirationDate forKey:kExpirationDateKey]; | ||
| } | ||
| #pragma mark - isEqual | ||
| - (BOOL)isEqual:(nullable id)object { | ||
| if (object == nil) { | ||
| return NO; | ||
| } | ||
| if (self == object) { | ||
| return YES; | ||
| } | ||
| if (![object isKindOfClass:[GIDToken class]]) { | ||
Alex-4-Git marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| return NO; | ||
| } | ||
| return [self isEqualToToken:(GIDToken *)object]; | ||
| } | ||
| - (BOOL)isEqualToToken:(GIDToken *)otherToken { | ||
| return [_tokenString isEqual:otherToken.tokenString] && | ||
| [self isTheSameDate:_expirationDate with:otherToken.expirationDate]; | ||
| } | ||
| // The date is nullable in GIDToken. Two `nil` dates are considered equal so | ||
| // token equality check succeeds if token strings are equal and have no expiration. | ||
| - (BOOL)isTheSameDate:(nullable NSDate *)date1 | ||
| with:(nullable NSDate *)date2 { | ||
| if (!date1 && !date2) { | ||
Alex-4-Git marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| return YES; | ||
| } | ||
| return [date1 isEqualToDate:date2]; | ||
| } | ||
| - (NSUInteger)hash { | ||
| return [self.tokenString hash] ^ [self.expirationDate hash]; | ||
| } | ||
| @end | ||
| NS_ASSUME_NONNULL_END | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.