diff options
author | Xiangtian Dai <xiangtian@google.com> | 2017-09-26 13:17:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-26 13:17:41 -0700 |
commit | 06fbbd8ee01ece0ee4d4599f3abcaf544b2f1a99 (patch) | |
tree | 4a085c1977892fe0016a60aefce2f3e2dafd9705 /Firebase/Auth | |
parent | dc36b0a5d790b11b2701d947aaeef9769d06eb36 (diff) |
- Saves user metadata in keychain. (#305)
- Adds Swift stubs for the new API.
- Shows the `isNewUser` bit in the sample app.
Diffstat (limited to 'Firebase/Auth')
-rw-r--r-- | Firebase/Auth/Source/FIRUser.m | 9 | ||||
-rw-r--r-- | Firebase/Auth/Source/FIRUserMetadata.m | 4 | ||||
-rw-r--r-- | Firebase/Auth/Source/FIRUserMetadata_Internal.h | 6 |
3 files changed, 14 insertions, 5 deletions
diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m index d24a2bf..049bb30 100644 --- a/Firebase/Auth/Source/FIRUser.m +++ b/Firebase/Auth/Source/FIRUser.m @@ -112,6 +112,11 @@ static NSString *const kAPIKeyCodingKey = @"APIKey"; */ static NSString *const kTokenServiceCodingKey = @"tokenService"; +/** @var kMetadataCodingKey + @brief The key used to encode the metadata instance variable for NSSecureCoding. + */ +static NSString *const kMetadataCodingKey = @"metadata"; + /** @var kMissingUsersErrorMessage @brief The error message when there is no users array in the getAccountInfo response. */ @@ -305,6 +310,8 @@ static void callInMainThreadWithAuthDataResultAndError( [aDecoder decodeObjectOfClasses:providerDataClasses forKey:kProviderDataKey]; FIRSecureTokenService *tokenService = [aDecoder decodeObjectOfClass:[FIRSecureTokenService class] forKey:kTokenServiceCodingKey]; + FIRUserMetadata *metadata = + [aDecoder decodeObjectOfClass:[FIRUserMetadata class] forKey:kMetadataCodingKey]; if (!userID || !tokenService) { return nil; } @@ -322,6 +329,7 @@ static void callInMainThreadWithAuthDataResultAndError( _photoURL = photoURL; _providerData = providerData; _phoneNumber = phoneNumber; + _metadata = metadata ?: [[FIRUserMetadata alloc] initWithCreationDate:nil lastSignInDate:nil]; } return self; } @@ -336,6 +344,7 @@ static void callInMainThreadWithAuthDataResultAndError( [aCoder encodeBool:_emailVerified forKey:kEmailVerifiedCodingKey]; [aCoder encodeObject:_photoURL forKey:kPhotoURLCodingKey]; [aCoder encodeObject:_displayName forKey:kDisplayNameCodingKey]; + [aCoder encodeObject:_metadata forKey:kMetadataCodingKey]; // The API key is encoded even it is not used in decoding to be compatible with previous versions // of the library. [aCoder encodeObject:_auth.requestConfiguration.APIKey forKey:kAPIKeyCodingKey]; diff --git a/Firebase/Auth/Source/FIRUserMetadata.m b/Firebase/Auth/Source/FIRUserMetadata.m index 65ca15c..8fe6509 100644 --- a/Firebase/Auth/Source/FIRUserMetadata.m +++ b/Firebase/Auth/Source/FIRUserMetadata.m @@ -30,8 +30,8 @@ static NSString *const kCreationDateCodingKey = @"creationDate"; */ static NSString *const kLastSignInDateCodingKey = @"lastSignInDate"; -- (nullable instancetype)initWithCreationDate:(NSDate *)creationDate - lastSignInDate:(NSDate *)lastSignInDate { +- (instancetype)initWithCreationDate:(nullable NSDate *)creationDate + lastSignInDate:(nullable NSDate *)lastSignInDate { self = [super init]; if (self) { _creationDate = [creationDate copy]; diff --git a/Firebase/Auth/Source/FIRUserMetadata_Internal.h b/Firebase/Auth/Source/FIRUserMetadata_Internal.h index 3fd1efc..0b01a03 100644 --- a/Firebase/Auth/Source/FIRUserMetadata_Internal.h +++ b/Firebase/Auth/Source/FIRUserMetadata_Internal.h @@ -25,13 +25,13 @@ NS_ASSUME_NONNULL_BEGIN */ @interface FIRUserMetadata () <NSSecureCoding> -/** @fn initWithCreationDate +/** @fn initWithCreationDate:lastSignInDate: @brief Designated initializer. @param creationDate The creation date of the corresponding user. @param lastSignInDate The date of the last recorded sign-in of the corresponding user. */ -- (nullable instancetype)initWithCreationDate:(NSDate *)creationDate - lastSignInDate:(NSDate *)lastSignInDate NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithCreationDate:(nullable NSDate *)creationDate + lastSignInDate:(nullable NSDate *)lastSignInDate NS_DESIGNATED_INITIALIZER; @end |