11'use strict' ;
2- const admin = require ( 'firebase-admin' ) ;
3- admin . initializeApp ( ) ;
2+ const { initializeApp } = require ( 'firebase-admin/app' ) ;
3+ const { getAuth } = require ( 'firebase-admin/auth' ) ;
4+ initializeApp ( ) ;
45
56// [START init_action_code_settings]
67const actionCodeSettings = {
@@ -17,73 +18,59 @@ const actionCodeSettings = {
1718 installApp : true ,
1819 minimumVersion : '12' ,
1920 } ,
20- // FDL custom domain.
21- dynamicLinkDomain : 'coolapp.page.link ' ,
21+ // The domain must be configured in Firebase Hosting and owned by the project .
22+ linkDomain : 'custom-domain.com ' ,
2223} ;
2324// [END init_action_code_settings]
2425
2526// [START password_reset_link]
2627// Admin SDK API to generate the password reset link.
2728const userEmail = '[email protected] ' ; 28- admin
29- . auth ( )
29+ getAuth ( )
3030 . generatePasswordResetLink ( userEmail , actionCodeSettings )
3131 . then ( ( link ) => {
3232 // Construct password reset email template, embed the link and send
3333 // using custom SMTP server.
34- return sendCustomPasswordResetEmail ( email , displayName , link ) ;
34+ return sendCustomPasswordResetEmail ( userEmail , displayName , link ) ;
3535 } )
3636 . catch ( ( error ) => {
3737 // Some error occurred.
3838 } ) ;
3939// [END password_reset_link]
4040
41- // [START email_verification_link]
42- // Admin SDK API to generate the password reset link.
43- const email = '[email protected] ' ; 44- admin
45- . auth ( )
46- . generatePasswordResetLink ( email , actionCodeSettings )
47- . then ( ( link ) => {
48- // Construct password reset email template, embed the link and send
49- // using custom SMTP server.
50- return sendCustomPasswordResetEmail ( email , displayName , link ) ;
51- } )
52- . catch ( ( error ) => {
53- // Some error occurred.
54- } ) ;
55-
56- // [START email_verification_link]
57- // Admin SDK API to generate the email verification link.
58- const useremail = '[email protected] ' ; 59- admin
60- . auth ( )
61- . generateEmailVerificationLink ( useremail , actionCodeSettings )
62- . then ( ( link ) => {
63- // Construct email verification template, embed the link and send
64- // using custom SMTP server.
65- return sendCustomVerificationEmail ( useremail , displayName , link ) ;
66- } )
67- . catch ( ( error ) => {
68- // Some error occurred.
69- } ) ;
70- // [END email_verification_link]
41+ function emailVerificationLink ( ) {
42+ // [START email_verification_link]
43+ // Admin SDK API to generate the email verification link.
44+ const useremail = '[email protected] ' ; 45+ getAuth ( )
46+ . generateEmailVerificationLink ( useremail , actionCodeSettings )
47+ . then ( ( link ) => {
48+ // Construct email verification template, embed the link and send
49+ // using custom SMTP server.
50+ return sendCustomVerificationEmail ( useremail , displayName , link ) ;
51+ } )
52+ . catch ( ( error ) => {
53+ // Some error occurred.
54+ } ) ;
55+ // [END email_verification_link]
56+ }
7157
72- // [START sign_in_with_email_link]
73- // Admin SDK API to generate the sign in with email link.
74- const usremail = '[email protected] ' ; 75- admin
76- . auth ( )
77- . generateSignInWithEmailLink ( usremail , actionCodeSettings )
78- . then ( ( link ) => {
79- // Construct sign-in with email link template, embed the link and
80- // send using custom SMTP server.
81- return sendSignInEmail ( usremail , displayName , link ) ;
82- } )
83- . catch ( ( error ) => {
84- // Some error occurred.
85- } ) ;
86- // [END sign_in_with_email_link]
58+ function signInWithEmailLink ( ) {
59+ // [START sign_in_with_email_link]
60+ // Admin SDK API to generate the sign in with email link.
61+ const useremail = '[email protected] ' ; 62+ getAuth ( )
63+ . generateSignInWithEmailLink ( useremail , actionCodeSettings )
64+ . then ( ( link ) => {
65+ // Construct sign-in with email link template, embed the link and
66+ // send using custom SMTP server.
67+ return sendSignInEmail ( useremail , displayName , link ) ;
68+ } )
69+ . catch ( ( error ) => {
70+ // Some error occurred.
71+ } ) ;
72+ // [END sign_in_with_email_link]
73+ }
8774
8875let displayName ;
8976const sendSignInEmail = ( ...args ) => {
0 commit comments