@@ -64,9 +64,10 @@ func (settings *ActionCodeSettings) toMap() (map[string]interface{}, error) {
64
64
type linkType string
65
65
66
66
const (
67
- emailLinkSignIn linkType = "EMAIL_SIGNIN"
68
- emailVerification linkType = "VERIFY_EMAIL"
69
- passwordReset linkType = "PASSWORD_RESET"
67
+ emailLinkSignIn linkType = "EMAIL_SIGNIN"
68
+ emailVerification linkType = "VERIFY_EMAIL"
69
+ passwordReset linkType = "PASSWORD_RESET"
70
+ verifyAndChangeEmail linkType = "VERIFY_AND_CHANGE_EMAIL"
70
71
)
71
72
72
73
// EmailVerificationLink generates the out-of-band email action link for email verification flows for the specified
@@ -79,7 +80,7 @@ func (c *baseClient) EmailVerificationLink(ctx context.Context, email string) (s
79
80
// specified email address, using the action code settings provided.
80
81
func (c * baseClient ) EmailVerificationLinkWithSettings (
81
82
ctx context.Context , email string , settings * ActionCodeSettings ) (string , error ) {
82
- return c .generateEmailActionLink (ctx , emailVerification , email , settings )
83
+ return c .generateEmailActionLink (ctx , emailVerification , email , settings , nil )
83
84
}
84
85
85
86
// PasswordResetLink generates the out-of-band email action link for password reset flows for the specified email
@@ -92,18 +93,31 @@ func (c *baseClient) PasswordResetLink(ctx context.Context, email string) (strin
92
93
// specified email address, using the action code settings provided.
93
94
func (c * baseClient ) PasswordResetLinkWithSettings (
94
95
ctx context.Context , email string , settings * ActionCodeSettings ) (string , error ) {
95
- return c .generateEmailActionLink (ctx , passwordReset , email , settings )
96
+ return c .generateEmailActionLink (ctx , passwordReset , email , settings , nil )
96
97
}
97
98
98
99
// EmailSignInLink generates the out-of-band email action link for email link sign-in flows, using the action
99
100
// code settings provided.
100
101
func (c * baseClient ) EmailSignInLink (
101
102
ctx context.Context , email string , settings * ActionCodeSettings ) (string , error ) {
102
- return c .generateEmailActionLink (ctx , emailLinkSignIn , email , settings )
103
+ return c .generateEmailActionLink (ctx , emailLinkSignIn , email , settings , nil )
104
+ }
105
+
106
+ // VerifyAndChangeEmailLink generates the out-of-band email action link for email verification and change flows for the
107
+ // specified email address.
108
+ func (c * baseClient ) VerifyAndChangeEmailLink (ctx context.Context , email string , newEmail string ) (string , error ) {
109
+ return c .VerifyAndChangeEmailLinkWithSettings (ctx , email , newEmail , nil )
110
+ }
111
+
112
+ // VerifyAndChangeEmailLinkWithSettings generates the out-of-band email action link for email verification and change
113
+ // flows for the specified email address, using the action code settings provided.
114
+ func (c * baseClient ) VerifyAndChangeEmailLinkWithSettings (
115
+ ctx context.Context , email string , newEmail string , settings * ActionCodeSettings ) (string , error ) {
116
+ return c .generateEmailActionLink (ctx , verifyAndChangeEmail , email , settings , & newEmail )
103
117
}
104
118
105
119
func (c * baseClient ) generateEmailActionLink (
106
- ctx context.Context , linkType linkType , email string , settings * ActionCodeSettings ) (string , error ) {
120
+ ctx context.Context , linkType linkType , email string , settings * ActionCodeSettings , newEmail * string ) (string , error ) {
107
121
108
122
if email == "" {
109
123
return "" , errors .New ("email must not be empty" )
@@ -118,6 +132,14 @@ func (c *baseClient) generateEmailActionLink(
118
132
"email" : email ,
119
133
"returnOobLink" : true ,
120
134
}
135
+
136
+ if linkType == verifyAndChangeEmail {
137
+ if newEmail == nil {
138
+ return "" , errors .New ("newEmail must not be nil when linkType is verifyAndChangeEmail" )
139
+ }
140
+ payload ["newEmail" ] = * newEmail
141
+ }
142
+
121
143
if settings != nil {
122
144
settingsMap , err := settings .toMap ()
123
145
if err != nil {
0 commit comments