Skip to content

Commit 056a0c1

Browse files
graeme-verticalscopegoogle-oss-botlahirumaramba
authored
feat(auth): Update ActionCodeSettings to support LinkDomain and deprecate DynamicLinkDomain (#703)
* [chore] Release 4.12.0 (#561) - Release 4.12.0 * Revert "[chore] Release 4.12.0 (#561)" (#565) This reverts commit 32af2b8. * Add LinkDomain to ActionCodeSettings * Handle INVALID_HOSTING_LINK_DOMAIN * Mark DynamicLinkDomain as deprecated * Better error message for INVALID_HOSTING_LINK_DOMAIN --------- Co-authored-by: Google Open Source Bot <26440463+google-oss-bot@users.noreply.github.com> Co-authored-by: Lahiru Maramba <llahiru@gmail.com> Co-authored-by: Google Open Source Bot <firebase-oss-bot@google.com>
1 parent 9b23ddc commit 056a0c1

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

auth/email_action_links.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ type ActionCodeSettings struct {
3131
AndroidPackageName string `json:"androidPackageName,omitempty"`
3232
AndroidMinimumVersion string `json:"androidMinimumVersion,omitempty"`
3333
AndroidInstallApp bool `json:"androidInstallApp,omitempty"`
34-
DynamicLinkDomain string `json:"dynamicLinkDomain,omitempty"`
34+
LinkDomain string `json:"linkDomain,omitempty"`
35+
// Deprecated: Use LinkDomain instead.
36+
DynamicLinkDomain string `json:"dynamicLinkDomain,omitempty"`
3537
}
3638

3739
func (settings *ActionCodeSettings) toMap() (map[string]interface{}, error) {

auth/email_action_links_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var testActionLinkResponse = []byte(fmt.Sprintf(testActionLinkFormat, testAction
3535
var testActionCodeSettings = &ActionCodeSettings{
3636
URL: "https://example.dynamic.link",
3737
HandleCodeInApp: true,
38+
LinkDomain: "hosted.page.link",
3839
DynamicLinkDomain: "custom.page.link",
3940
IOSBundleID: "com.example.ios",
4041
AndroidPackageName: "com.example.android",
@@ -44,6 +45,7 @@ var testActionCodeSettings = &ActionCodeSettings{
4445
var testActionCodeSettingsMap = map[string]interface{}{
4546
"continueUrl": "https://example.dynamic.link",
4647
"canHandleCodeInApp": true,
48+
"linkDomain": "hosted.page.link",
4749
"dynamicLinkDomain": "custom.page.link",
4850
"iOSBundleId": "com.example.ios",
4951
"androidPackageName": "com.example.android",
@@ -293,6 +295,7 @@ func TestEmailVerificationLinkError(t *testing.T) {
293295
cases := map[string]func(error) bool{
294296
"UNAUTHORIZED_DOMAIN": IsUnauthorizedContinueURI,
295297
"INVALID_DYNAMIC_LINK_DOMAIN": IsInvalidDynamicLinkDomain,
298+
"INVALID_HOSTING_LINK_DOMAIN": IsInvalidHostingLinkDomain,
296299
}
297300
s := echoServer(testActionLinkResponse, t)
298301
defer s.Close()

auth/user_mgt.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ const (
522522
emailAlreadyExists = "EMAIL_ALREADY_EXISTS"
523523
emailNotFound = "EMAIL_NOT_FOUND"
524524
invalidDynamicLinkDomain = "INVALID_DYNAMIC_LINK_DOMAIN"
525+
invalidHostingLinkDomain = "INVALID_HOSTING_LINK_DOMAIN"
525526
phoneNumberAlreadyExists = "PHONE_NUMBER_ALREADY_EXISTS"
526527
tenantNotFound = "TENANT_NOT_FOUND"
527528
uidAlreadyExists = "UID_ALREADY_EXISTS"
@@ -556,6 +557,11 @@ func IsInvalidDynamicLinkDomain(err error) bool {
556557
return hasAuthErrorCode(err, invalidDynamicLinkDomain)
557558
}
558559

560+
// IsInvalidHostingLinkDomain checks if the given error was due to an invalid hosting link domain.
561+
func IsInvalidHostingLinkDomain(err error) bool {
562+
return hasAuthErrorCode(err, invalidHostingLinkDomain)
563+
}
564+
559565
// IsInvalidEmail checks if the given error was due to an invalid email.
560566
//
561567
// Deprecated: Always returns false.
@@ -1447,6 +1453,11 @@ var serverError = map[string]*authError{
14471453
message: "the provided dynamic link domain is not configured or authorized for the current project",
14481454
authCode: invalidDynamicLinkDomain,
14491455
},
1456+
"INVALID_HOSTING_LINK_DOMAIN": {
1457+
code: internal.InvalidArgument,
1458+
message: "the provided hosting link domain is not configured in Firebase Hosting or is not owned by the current project",
1459+
authCode: invalidHostingLinkDomain,
1460+
},
14501461
"PHONE_NUMBER_EXISTS": {
14511462
code: internal.AlreadyExists,
14521463
message: "user with the provided phone number already exists",

auth/user_mgt_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,11 @@ func TestHTTPErrorWithCode(t *testing.T) {
21512151
errorutils.IsInvalidArgument,
21522152
"the provided dynamic link domain is not configured or authorized for the current project",
21532153
},
2154+
"INVALID_HOSTING_LINK_DOMAIN": {
2155+
IsInvalidHostingLinkDomain,
2156+
errorutils.IsInvalidArgument,
2157+
"the provided hosting link domain is not configured in Firebase Hosting or is not owned by the current project",
2158+
},
21542159
"PHONE_NUMBER_EXISTS": {
21552160
IsPhoneNumberAlreadyExists,
21562161
errorutils.IsAlreadyExists,

0 commit comments

Comments
 (0)