-
Notifications
You must be signed in to change notification settings - Fork 144
feat(auth): Add LinkDomain
to ActionCodeSettings
and deprecate DynamicLinkDomain
#475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
a7b053f
d5f30d3
de8b5a7
abb8251
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,17 @@ public class EmailActionRequestTest | |
new ActionCodeSettings() | ||
{ | ||
Url = "https://example.dynamic.link", | ||
#pragma warning disable CS0618 | ||
DynamicLinkDomain = string.Empty, | ||
#pragma warning restore CS0618 | ||
}, | ||
}, | ||
new object[] | ||
{ | ||
new ActionCodeSettings() | ||
{ | ||
Url = "https://example.dynamic.link", | ||
LinkDomain = string.Empty, | ||
}, | ||
}, | ||
new object[] | ||
|
@@ -84,7 +94,10 @@ public class EmailActionRequestTest | |
{ | ||
Url = "https://example.dynamic.link", | ||
HandleCodeInApp = true, | ||
#pragma warning disable CS0618 | ||
DynamicLinkDomain = "custom.page.link", | ||
#pragma warning restore CS0618 | ||
LinkDomain = "custom.page.link", | ||
IosBundleId = "com.example.ios", | ||
AndroidPackageName = "com.example.android", | ||
AndroidMinimumVersion = "6", | ||
|
@@ -163,14 +176,17 @@ public async Task EmailVerificationLinkWithSettings() | |
|
||
var request = NewtonsoftJsonSerializer.Instance.Deserialize<Dictionary<string, object>>( | ||
handler.LastRequestBody); | ||
Assert.Equal(10, request.Count); | ||
Assert.Equal(11, request.Count); | ||
Assert.Equal("[email protected]", request["email"]); | ||
Assert.Equal("VERIFY_EMAIL", request["requestType"]); | ||
Assert.True((bool)request["returnOobLink"]); | ||
|
||
Assert.Equal(ActionCodeSettings.Url, request["continueUrl"]); | ||
Assert.True((bool)request["canHandleCodeInApp"]); | ||
#pragma warning disable CS0618 | ||
Assert.Equal(ActionCodeSettings.DynamicLinkDomain, request["dynamicLinkDomain"]); | ||
#pragma warning restore CS0618 | ||
Assert.Equal(ActionCodeSettings.LinkDomain, request["linkDomain"]); | ||
Assert.Equal(ActionCodeSettings.IosBundleId, request["iOSBundleId"]); | ||
Assert.Equal(ActionCodeSettings.AndroidPackageName, request["androidPackageName"]); | ||
Assert.Equal( | ||
|
@@ -229,14 +245,17 @@ public async Task PasswordResetLinkWithSettings() | |
|
||
var request = NewtonsoftJsonSerializer.Instance.Deserialize<Dictionary<string, object>>( | ||
handler.LastRequestBody); | ||
Assert.Equal(10, request.Count); | ||
Assert.Equal(11, request.Count); | ||
Assert.Equal("[email protected]", request["email"]); | ||
Assert.Equal("PASSWORD_RESET", request["requestType"]); | ||
Assert.True((bool)request["returnOobLink"]); | ||
|
||
Assert.Equal(ActionCodeSettings.Url, request["continueUrl"]); | ||
Assert.True((bool)request["canHandleCodeInApp"]); | ||
#pragma warning disable CS0618 | ||
Assert.Equal(ActionCodeSettings.DynamicLinkDomain, request["dynamicLinkDomain"]); | ||
#pragma warning restore CS0618 | ||
Assert.Equal(ActionCodeSettings.LinkDomain, request["linkDomain"]); | ||
Assert.Equal(ActionCodeSettings.IosBundleId, request["iOSBundleId"]); | ||
Assert.Equal(ActionCodeSettings.AndroidPackageName, request["androidPackageName"]); | ||
Assert.Equal( | ||
|
@@ -287,14 +306,17 @@ public async Task SignInWithEmailLink() | |
|
||
var request = NewtonsoftJsonSerializer.Instance.Deserialize<Dictionary<string, object>>( | ||
handler.LastRequestBody); | ||
Assert.Equal(10, request.Count); | ||
Assert.Equal(11, request.Count); | ||
Assert.Equal("[email protected]", request["email"]); | ||
Assert.Equal("EMAIL_SIGNIN", request["requestType"]); | ||
Assert.True((bool)request["returnOobLink"]); | ||
|
||
Assert.Equal(ActionCodeSettings.Url, request["continueUrl"]); | ||
Assert.True((bool)request["canHandleCodeInApp"]); | ||
#pragma warning disable CS0618 | ||
Assert.Equal(ActionCodeSettings.DynamicLinkDomain, request["dynamicLinkDomain"]); | ||
#pragma warning restore CS0618 | ||
Assert.Equal(ActionCodeSettings.LinkDomain, request["linkDomain"]); | ||
Assert.Equal(ActionCodeSettings.IosBundleId, request["iOSBundleId"]); | ||
Assert.Equal(ActionCodeSettings.AndroidPackageName, request["androidPackageName"]); | ||
Assert.Equal( | ||
|
@@ -351,6 +373,39 @@ public async Task InvalidDynamicLinkDomain() | |
Assert.Null(exception.InnerException); | ||
} | ||
|
||
[Fact] | ||
public async Task InvalidHostingLinkDomain() | ||
{ | ||
var json = $@"{{ | ||
""error"": {{ | ||
""message"": ""INVALID_HOSTING_LINK_DOMAIN"", | ||
}} | ||
}}"; | ||
var handler = new MockMessageHandler() | ||
{ | ||
StatusCode = HttpStatusCode.InternalServerError, | ||
Response = json, | ||
}; | ||
var auth = this.CreateFirebaseAuth(handler); | ||
var settings = new ActionCodeSettings() | ||
{ | ||
Url = "https://example.dynamic.link", | ||
LinkDomain = "custom.page.link", | ||
}; | ||
|
||
var exception = await Assert.ThrowsAsync<FirebaseAuthException>( | ||
async () => await auth.GenerateSignInWithEmailLinkAsync( | ||
"[email protected]", settings)); | ||
|
||
Assert.Equal(ErrorCode.InvalidArgument, exception.ErrorCode); | ||
Assert.Equal(AuthErrorCode.InvalidHostingLinkDomain, exception.AuthErrorCode); | ||
Assert.Equal( | ||
"The provided hosting link domain is not configured in Firebase Hosting or is not owned by the current project (INVALID_HOSTING_LINK_DOMAIN).", | ||
exception.Message); | ||
Assert.NotNull(exception.HttpResponse); | ||
Assert.Null(exception.InnerException); | ||
} | ||
|
||
private FirebaseAuth CreateFirebaseAuth(HttpMessageHandler handler) | ||
{ | ||
var userManager = new FirebaseUserManager(new FirebaseUserManager.Args | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,13 @@ internal sealed class AuthErrorHandler | |
AuthErrorCode.InvalidDynamicLinkDomain, | ||
"Dynamic link domain specified in ActionCodeSettings is not authorized") | ||
}, | ||
{ | ||
"INVALID_HOSTING_LINK_DOMAIN", | ||
new ErrorInfo( | ||
ErrorCode.InvalidArgument, | ||
AuthErrorCode.InvalidHostingLinkDomain, | ||
"The provided hosting link domain is not configured in Firebase Hosting or is not owned by the current project") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these error message same accross all SDKs? Also the message looks confusing for the developers "Cant we just say he provided hosting link domain is not configured in Firebase Hosting for this project" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do use that same error message across the other SDKs: |
||
}, | ||
{ | ||
"PHONE_NUMBER_EXISTS", | ||
new ErrorInfo( | ||
|
Uh oh!
There was an error while loading. Please reload this page.