aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Auth/Sample/MainViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Example/Auth/Sample/MainViewController.m')
-rw-r--r--Example/Auth/Sample/MainViewController.m30
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.
*/