diff options
author | Zsika Phillip <protocol86@users.noreply.github.com> | 2018-03-14 18:38:55 -0700 |
---|---|---|
committer | Paul Beusterien <paulbeusterien@google.com> | 2018-03-14 18:38:55 -0700 |
commit | 7e65885762757209e0e14ec28e99ec91380e9c2f (patch) | |
tree | 9c8820da0c68496358ec9d2d436d74f39b67ffd1 /Example/Auth | |
parent | 7b960fdf5986b1a7ef989125fe461d08f6aa8389 (diff) |
Add sign in method constants (#923)
* Updates Changelog for 4.5.0 release
* Adds sign-in method constants
Diffstat (limited to 'Example/Auth')
-rw-r--r-- | Example/Auth/Sample/MainViewController.m | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Example/Auth/Sample/MainViewController.m b/Example/Auth/Sample/MainViewController.m index 36ef92d..f6893d1 100644 --- a/Example/Auth/Sample/MainViewController.m +++ b/Example/Auth/Sample/MainViewController.m @@ -96,6 +96,11 @@ static NSString *const kSignInGoogleButtonText = @"Sign in with Google"; */ static NSString *const kSignInWithEmailLink = @"Sign in with Email Link"; +/** @var kVerifyEmailLinkAccount + @brief The text of the "Verify Email-link Account" button. + */ +static NSString *const kVerifyEmailLinkAccount = @"Verify Email-link Account"; + /** @var kSendEmailSignInLink @brief The text of the "Send Email SignIn link" button */ @@ -739,6 +744,8 @@ typedef enum { action:^{ [weakSelf signInGoogle]; }], [StaticContentTableViewCell cellWithTitle:kSignInWithEmailLink action:^{ [weakSelf signInWithEmailLink]; }], + [StaticContentTableViewCell cellWithTitle:kVerifyEmailLinkAccount + action:^{ [weakSelf verifyEmailLinkAccount]; }], [StaticContentTableViewCell cellWithTitle:kSendEmailSignInLink action:^{ [weakSelf sendEmailSignInLink]; }], [StaticContentTableViewCell cellWithTitle:kSignInGoogleAndRetrieveDataButtonText @@ -1784,6 +1791,29 @@ static NSDictionary<NSString *, NSString *> *parseURL(NSString *urlString) { }]; } +/** @fn verifyEmailLinkAccount + @brief Invoked to verify that the current user is an email-link user. + */ +- (void)verifyEmailLinkAccount { + if (![FIRAuth auth].currentUser.email) { + [self showMessagePrompt:@"There is no signed-in user available."]; + return; + } + [[FIRAuth auth] fetchSignInMethodsForEmail:[FIRAuth auth].currentUser.email + completion:^(NSArray<NSString *> *_Nullable signInMethods, + NSError *_Nullable error) { + if (error) { + [self showMessagePrompt:@"There was an error fetching sign-in methods."]; + return; + } + if (![signInMethods containsObject:FIREmailLinkAuthSignInMethod]) { + [self showMessagePrompt:@"Error: The current user is NOT an email-link user."]; + return; + } + [self showMessagePrompt:@"The current user is an email-link user."]; + }]; +} + /** @fn sendEmailSignInLink @brief Invoked when "Send email sign-in link" row is pressed. */ |