From 7e65885762757209e0e14ec28e99ec91380e9c2f Mon Sep 17 00:00:00 2001 From: Zsika Phillip Date: Wed, 14 Mar 2018 18:38:55 -0700 Subject: Add sign in method constants (#923) * Updates Changelog for 4.5.0 release * Adds sign-in method constants --- Example/Auth/Sample/MainViewController.m | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'Example') 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 *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 *_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. */ -- cgit v1.2.3