Skip to content

Commit 0cc651a

Browse files
author
Chuan Ren
authored
Merge pull request #588 from firebase/emaillink
Add email link sign in support
2 parents e63617c + cd3e634 commit 0cc651a

File tree

106 files changed

+3126
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+3126
-348
lines changed

Auth/FirebaseAuthUI/FUIAuth.m

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,20 @@ - (BOOL)handleOpenURL:(NSURL *)URL
124124
}
125125

126126
- (UINavigationController *)authViewController {
127-
UIViewController *controller;
127+
static UINavigationController *authViewController;
128128

129-
if ([self.delegate respondsToSelector:@selector(authPickerViewControllerForAuthUI:)]) {
130-
controller = [self.delegate authPickerViewControllerForAuthUI:self];
131-
} else {
132-
controller = [[FUIAuthPickerViewController alloc] initWithAuthUI:self];
133-
}
134-
return [[UINavigationController alloc] initWithRootViewController:controller];
129+
static dispatch_once_t onceToken;
130+
dispatch_once(&onceToken, ^{
131+
UIViewController *controller;
132+
if ([self.delegate respondsToSelector:@selector(authPickerViewControllerForAuthUI:)]) {
133+
controller = [self.delegate authPickerViewControllerForAuthUI:self];
134+
} else {
135+
controller = [[FUIAuthPickerViewController alloc] initWithAuthUI:self];
136+
}
137+
authViewController = [[UINavigationController alloc] initWithRootViewController:controller];
138+
});
139+
140+
return authViewController;
135141
}
136142

137143
- (BOOL)signOutWithError:(NSError *_Nullable *_Nullable)error {

Auth/FirebaseAuthUI/FUIAuthBaseViewController.m

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -218,59 +218,76 @@ - (void)showAlertWithMessage:(NSString *)message {
218218
[[self class] showAlertWithMessage:message presentingViewController:self];
219219
}
220220

221+
+ (void)showAlertWithMessage:(NSString *)message {
222+
[[self class] showAlertWithMessage:message presentingViewController:nil];
223+
}
224+
221225
+ (void)showAlertWithMessage:(NSString *)message
222-
presentingViewController:(UIViewController *)presentingViewController {
223-
[[self class] showAlertWithTitle:nil
224-
message:message
225-
actionTitle:FUILocalizedString(kStr_OK)
226+
presentingViewController:(nullable UIViewController *)presentingViewController {
227+
[[self class] showAlertWithTitle:message
228+
message:nil
226229
presentingViewController:presentingViewController];
227230
}
228231

229232
+ (void)showAlertWithTitle:(nullable NSString *)title
230-
message:(NSString *)message
231-
actionTitle:(NSString *)actionTitle
232-
presentingViewController:(UIViewController *)presentingViewController {
233-
UIAlertController *alertController =
234-
[UIAlertController alertControllerWithTitle:title
235-
message:message
236-
preferredStyle:UIAlertControllerStyleAlert];
237-
UIAlertAction *okAction =
238-
[UIAlertAction actionWithTitle:actionTitle
239-
style:UIAlertActionStyleDefault
240-
handler:nil];
241-
[alertController addAction:okAction];
242-
[presentingViewController presentViewController:alertController animated:YES completion:nil];
233+
message:(nullable NSString *)message
234+
presentingViewController:(nullable UIViewController *)presentingViewController {
235+
[[self class] showAlertWithTitle:title
236+
message:message
237+
actionTitle:nil
238+
actionHandler:nil
239+
dismissTitle:FUILocalizedString(kStr_OK)
240+
dismissHandler:nil
241+
presentingViewController:presentingViewController];
243242
}
244243

245244
+ (void)showAlertWithTitle:(nullable NSString *)title
246-
message:(NSString *)message
247-
actionTitle:(NSString *)actionTitle
248-
presentingViewController:(UIViewController *)presentingViewController
249-
actionHandler:(FUIAuthAlertActionHandler)actionHandler
250-
cancelHandler:(FUIAuthAlertActionHandler)cancelHandler {
245+
message:(nullable NSString *)message
246+
actionTitle:(nullable NSString *)actionTitle
247+
actionHandler:(nullable FUIAuthAlertActionHandler)actionHandler
248+
dismissTitle:(nullable NSString *)dismissTitle
249+
dismissHandler:(nullable FUIAuthAlertActionHandler)dismissHandler
250+
presentingViewController:(nullable UIViewController *)presentingViewController {
251251
UIAlertController *alertController =
252252
[UIAlertController alertControllerWithTitle:title
253253
message:message
254254
preferredStyle:UIAlertControllerStyleAlert];
255-
UIAlertAction *okAction =
256-
[UIAlertAction actionWithTitle:actionTitle
257-
style:UIAlertActionStyleDefault
258-
handler:^(UIAlertAction *_Nonnull action) {
259-
if (actionHandler) {
260-
actionHandler();
261-
}
262-
}];
263-
[alertController addAction:okAction];
264-
UIAlertAction *cancelAction =
265-
[UIAlertAction actionWithTitle:FUILocalizedString(kStr_Cancel)
266-
style:UIAlertActionStyleCancel
255+
256+
if (actionTitle) {
257+
UIAlertAction *action =
258+
[UIAlertAction actionWithTitle:actionTitle
259+
style:UIAlertActionStyleDefault
260+
handler:^(UIAlertAction *_Nonnull action) {
261+
if (actionHandler) {
262+
actionHandler();
263+
}
264+
}];
265+
[alertController addAction:action];
266+
}
267+
268+
if (dismissTitle) {
269+
UIAlertAction *dismissAction =
270+
[UIAlertAction actionWithTitle:dismissTitle
271+
style:UIAlertActionStyleCancel
267272
handler:^(UIAlertAction * _Nonnull action) {
268-
if (cancelHandler) {
269-
cancelHandler();
270-
}
271-
}];
272-
[alertController addAction:cancelAction];
273-
[presentingViewController presentViewController:alertController animated:YES completion:nil];
273+
if (dismissHandler) {
274+
dismissHandler();
275+
}
276+
}];
277+
[alertController addAction:dismissAction];
278+
}
279+
280+
if (presentingViewController) {
281+
[presentingViewController presentViewController:alertController animated:YES completion:nil];
282+
} else {
283+
UIViewController *viewController = [[UIViewController alloc] init];
284+
viewController.view.backgroundColor = UIColor.clearColor;
285+
UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
286+
window.rootViewController = viewController;
287+
window.windowLevel = UIWindowLevelAlert + 1;
288+
[window makeKeyAndVisible];
289+
[viewController presentViewController:alertController animated:YES completion:nil];
290+
}
274291
}
275292

276293
+ (void)showSignInAlertWithEmail:(NSString *)email

Auth/FirebaseAuthUI/FUIAuthBaseViewController_Internal.h

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,57 +38,51 @@ NS_ASSUME_NONNULL_BEGIN
3838
*/
3939
- (void)showAlertWithMessage:(NSString *)message;
4040

41+
/** @fn showAlertWithMessage:
42+
@brief Displays an alert view with given title and message on top of the current view
43+
controller.
44+
@param message The message of the alert.
45+
*/
46+
+ (void)showAlertWithMessage:(NSString *)message;
47+
4148
/** @fn showAlertWithMessage:presentingViewController:
42-
@brief Displays an alert view with given title and message on top of the
43-
specified view controller.
44-
@param message The message of the alert.
45-
@param presentingViewController The controller which shows alert.
49+
@brief Displays an alert view with given title and message on top of the current view
50+
controller.
51+
@param message The message of the alert.
52+
@param presentingViewController The controller which shows alert.
4653
*/
4754
+ (void)showAlertWithMessage:(NSString *)message
48-
presentingViewController:(UIViewController *)presentingViewController;
55+
presentingViewController:(nullable UIViewController *)presentingViewController;
4956

50-
/** @fn showAlertWithTitle:message:actionTitle:presentingViewController:
51-
@brief Displays an alert view with given title, message and action title on top of the
57+
/** @fn showAlertWithTitle:message:
58+
@brief Displays an alert view with given title, message and action title on top of the
5259
specified view controller.
5360
@param title The title of the alert.
5461
@param message The message of the alert.
55-
@param actionTitle The title of the action button.
5662
@param presentingViewController The controller which shows alert.
57-
*/
63+
*/
5864
+ (void)showAlertWithTitle:(nullable NSString *)title
59-
message:(NSString *)message
60-
actionTitle:(NSString *)actionTitle
61-
presentingViewController:(UIViewController *)presentingViewController;
65+
message:(nullable NSString *)message
66+
presentingViewController:(nullable UIViewController *)presentingViewController;
6267

63-
/** @fn showAlertWithTitle:message:actionTitle:presentingViewController:
64-
@brief Displays an alert view with given title, message and action title on top of the
68+
/** @fn showAlertWithTitle:message:actionTitle:actionHandler:dismissTitle:dismissHandler:
69+
@brief Displays an alert view with given title, message and action title on top of the
6570
specified view controller.
6671
@param title The title of the alert.
6772
@param message The message of the alert.
6873
@param actionTitle The title of the action button.
6974
@param actionHandler The block to execute if the action button is tapped.
70-
@param cancelHandler The block to execute if the cancel button is tapped.
75+
@param dismissTitle The title of the dismiss button.
76+
@param dismissHandler The block to execute if the cancel button is tapped.
7177
@param presentingViewController The controller which shows alert.
72-
*/
78+
*/
7379
+ (void)showAlertWithTitle:(nullable NSString *)title
74-
message:(NSString *)message
75-
actionTitle:(NSString *)actionTitle
76-
presentingViewController:(UIViewController *)presentingViewController
77-
actionHandler:(FUIAuthAlertActionHandler)actionHandler
78-
cancelHandler:(FUIAuthAlertActionHandler)cancelHandler;
79-
80-
/** @fn showSignInAlertWithEmail:provider:handler:
81-
@brief Displays an alert to conform with user whether she wants to proceed with the provider.
82-
@param email The email address to sign in with.
83-
@param provider The identity provider to sign in with.
84-
@param signinHandler Handler for the sign in action of the alert.
85-
@param cancelHandler Handler for the cancel action of the alert.
86-
*/
87-
+ (void)showSignInAlertWithEmail:(NSString *)email
88-
provider:(id<FUIAuthProvider>)provider
89-
presentingViewController:(UIViewController *)presentingViewController
90-
signinHandler:(FUIAuthAlertActionHandler)signinHandler
91-
cancelHandler:(FUIAuthAlertActionHandler)cancelHandler;
80+
message:(nullable NSString *)message
81+
actionTitle:(nullable NSString *)actionTitle
82+
actionHandler:(nullable FUIAuthAlertActionHandler)actionHandler
83+
dismissTitle:(nullable NSString *)dismissTitle
84+
dismissHandler:(nullable FUIAuthAlertActionHandler)dismissHandler
85+
presentingViewController:(nullable UIViewController *)presentingViewController;
9286

9387
/** @fn showSignInAlertWithEmail:providerShortName:providerSignInLabel:handler:
9488
@brief Displays an alert to conform with user whether she wants to proceed with the provider.

Auth/FirebaseAuthUI/FUIAuthStrings.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ extern NSString *const kStr_Cancel;
3434
extern NSString *const kStr_CannotAuthenticateError;
3535
extern NSString *const kStr_ChoosePassword;
3636
extern NSString *const kStr_Close;
37+
extern NSString *const kStr_ConfirmEmail;
3738
extern NSString *const kStr_Email;
3839
extern NSString *const kStr_EmailAlreadyInUseError;
40+
extern NSString *const kStr_EmailSentConfirmationMessage;
3941
extern NSString *const kStr_EnterYourEmail;
4042
extern NSString *const kStr_EnterYourPassword;
4143
extern NSString *const kStr_Error;
@@ -56,12 +58,17 @@ extern NSString *const kStr_PasswordVerificationMessage;
5658
extern NSString *const kStr_ProviderUsedPreviouslyMessage;
5759
extern NSString *const kStr_Save;
5860
extern NSString *const kStr_Send;
61+
extern NSString *const kStr_Resend;
62+
extern NSString *const kStr_SignedIn;
5963
extern NSString *const kStr_SignInTitle;
6064
extern NSString *const kStr_SignInTooManyTimesError;
6165
extern NSString *const kStr_SignInWithEmail;
66+
extern NSString *const kStr_SignInEmailSent;
6267
extern NSString *const kStr_SignUpTitle;
6368
extern NSString *const kStr_SignUpTooManyTimesError;
6469
extern NSString *const kStr_TermsOfService;
70+
extern NSString *const kStr_TroubleGettingEmailTitle;
71+
extern NSString *const kStr_TroubleGettingEmailMessage;
6572
extern NSString *const kStr_PrivacyPolicy;
6673
extern NSString *const kStr_TermsOfServiceMessage;
6774
extern NSString *const kStr_UserNotFoundError;

Auth/FirebaseAuthUI/FUIAuthStrings.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
NSString *const kStr_CannotAuthenticateError = @"CannotAuthenticateError";
4141
NSString *const kStr_ChoosePassword = @"ChoosePassword";
4242
NSString *const kStr_Close = @"Close";
43+
NSString *const kStr_ConfirmEmail = @"ConfirmEmail";
4344
NSString *const kStr_Email = @"Email";
4445
NSString *const kStr_EmailAlreadyInUseError = @"EmailAlreadyInUseError";
46+
NSString *const kStr_EmailSentConfirmationMessage = @"EmailSentConfirmationMessage";
4547
NSString *const kStr_EnterYourEmail = @"EnterYourEmail";
4648
NSString *const kStr_EnterYourPassword = @"EnterYourPassword";
4749
NSString *const kStr_Error = @"Error";
@@ -62,12 +64,17 @@
6264
NSString *const kStr_ProviderUsedPreviouslyMessage = @"ProviderUsedPreviouslyMessage";
6365
NSString *const kStr_Save = @"Save";
6466
NSString *const kStr_Send = @"Send";
67+
NSString *const kStr_Resend = @"Resend";
68+
NSString *const kStr_SignedIn = @"SignedIn";
6569
NSString *const kStr_SignInTitle = @"SignInTitle";
6670
NSString *const kStr_SignInTooManyTimesError = @"SignInTooManyTimesError";
6771
NSString *const kStr_SignInWithEmail = @"SignInWithEmail";
72+
NSString *const kStr_SignInEmailSent = @"SignInEmailSent";
6873
NSString *const kStr_SignUpTitle = @"SignUpTitle";
6974
NSString *const kStr_SignUpTooManyTimesError = @"SignUpTooManyTimesError";
7075
NSString *const kStr_TermsOfService = @"TermsOfService";
76+
NSString *const kStr_TroubleGettingEmailTitle = @"TroubleGettingEmailTitle";
77+
NSString *const kStr_TroubleGettingEmailMessage = @"TroubleGettingEmailMessage";
7178
NSString *const kStr_PrivacyPolicy = @"PrivacyPolicy";
7279
NSString *const kStr_TermsOfServiceMessage = @"TermsOfServiceMessage";
7380
NSString *const kStr_UserNotFoundError = @"UserNotFoundError";

Auth/FirebaseAuthUI/Strings/ar.lproj/FirebaseAuthUI.strings

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@
103103
/* Save button title. */
104104
"Save" = "حفظ";
105105

106-
/* Save button title. */
106+
/* Send button title. */
107107
"Send" = "إرسال";
108108

109+
/* Resend button title. */
110+
"Resend" = "إعادة إرسال الرسالة";
111+
109112
/* Label next to a email text field. Use short/abbreviated translation for 'email' which is less than 15 chars. */
110113
"Email" = "البريد الإلكتروني";
111114

@@ -244,5 +247,23 @@
244247
/* Placeholder of secret input cell when user changes password. */
245248
"PlaceholderChosePassword" = "اختيار كلمة المرور";
246249

247-
/* The title of forgot password button. */
250+
/* Title of forgot password button. */
248251
"ForgotPasswordTitle" = "هل تواجه مشكلة في تسجيل الدخول؟";
252+
253+
/* Title of confirm email label. */
254+
"ConfirmEmail" = "تأكيد عنوان البريد الإلكتروني";
255+
256+
/* Title of successfully signed in label. */
257+
"SignedIn" = "تمّ تسجيل الدخول.";
258+
259+
/* Title used in trouble getting email alert view. */
260+
"TroubleGettingEmailTitle" = "هل تواجه مشكلة في استلام الرسائل الإلكترونية؟";
261+
262+
/* Alert message displayed when user having trouble getting email. */
263+
"TroubleGettingEmailMessage" = "يمكنك تجربة الحلول الشائعة التالية: \n - التأكّد ممّا إذا تمّ وضع علامة على الرسالة الإلكترونية بأنها \"غير مرغوب فيها\" أو نقلها تلقائيًا إلى مجلّد آخر\n - التحقّق من اتصال الإنترنت\n - التأكّد من كتابة عنوان البريد الإلكتروني بالشكل الصحيح\n - التأكّد من توفّر مساحة فارغة في البريد الوارد أو من عدم حدوث أي مشاكل أخرى في إعدادات البريد الوارد\n إذا لم تنجح الخطوات أعلاه، يمكنك إعادة إرسال الرسالة الإلكترونية. ستؤدي هذه الخطوة إلى إلغاء الرابط المضمّن في الرسالة السابقة.";
264+
265+
/* Message displayed after email is sent. The placeholder is the email address that the email is sent to. */
266+
"EmailSentConfirmationMessage" = "تمّ إرسال رسالة إلكترونية لتسجيل الدخول تتضمّن تعليمات إضافية إلى %@. يُرجى التحقق من بريدك الإلكتروني لإكمال عملية تسجيل الدخول.";
267+
268+
/* Message displayed after the email of sign-in link is sent. */
269+
"SignInEmailSent" = "تمّ إرسال رسالة إلكترونية لتسجيل الدخول";

Auth/FirebaseAuthUI/Strings/bg.lproj/FirebaseAuthUI.strings

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@
103103
/* Save button title. */
104104
"Save" = "Запазване";
105105

106-
/* Save button title. */
106+
/* Send button title. */
107107
"Send" = "Изпращане";
108108

109+
/* Resend button title. */
110+
"Resend" = "Повторно изпращане";
111+
109112
/* Label next to a email text field. Use short/abbreviated translation for 'email' which is less than 15 chars. */
110113
"Email" = "Имейл";
111114

@@ -244,5 +247,23 @@
244247
/* Placeholder of secret input cell when user changes password. */
245248
"PlaceholderChosePassword" = "Изберете парола";
246249

247-
/* The title of forgot password button. */
250+
/* Title of forgot password button. */
248251
"ForgotPasswordTitle" = "Имате проблем при влизането?";
252+
253+
/* Title of confirm email label. */
254+
"ConfirmEmail" = "Потвърждаване на имейл адреса";
255+
256+
/* Title of successfully signed in label. */
257+
"SignedIn" = "Влязохте в профила!";
258+
259+
/* Title used in trouble getting email alert view. */
260+
"TroubleGettingEmailTitle" = "Имате проблеми с получаването на имейла?";
261+
262+
/* Alert message displayed when user having trouble getting email. */
263+
"TroubleGettingEmailMessage" = "Изпробвайте следните често използвани решения: \n – Проверете дали имейлът не е обозначен и филтриран като спам.\n – Проверете връзката си с интернет.\n – Проверете дали имейлът е изписан правилно.\n – Проверете дали в пощенската ви кутия има достатъчно пространство, или не е налице друг проблем с настройките й.\n Ако стъпките по-горе не разрешат проблема, можете отново да изпратите имейла. Имайте предвид, че това ще деактивира връзката в предходното съобщение.";
264+
265+
/* Message displayed after email is sent. The placeholder is the email address that the email is sent to. */
266+
"EmailSentConfirmationMessage" = "Изпратихме имейл до %@ за вход в профила с допълнителни инструкции. Проверете входящата си поща, за да завършите процеса.";
267+
268+
/* Message displayed after the email of sign-in link is sent. */
269+
"SignInEmailSent" = "Изпратен е имейл за вход в профила";

0 commit comments

Comments
 (0)