Skip to content

fix: fix sign-in parameter identifier #34

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions samples/sample-blazor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@

/// <see href="https://docs.logto.io/docs/references/openid-connect/authentication-parameters/#first-screen"/>
/// <see cref="LogtoParameters.Authentication.FirstScreen"/>
authProperties.SetParameter("first_screen", LogtoParameters.Authentication.FirstScreen.Register);
authProperties.SetParameter("first_screen", LogtoParameters.Authentication.FirstScreen.SignIn);

// This parameter MUST be used together with `first_screen`.
authProperties.SetParameter("identifiers", string.Join(",", new[]
authProperties.SetParameter("identifiers", System.Text.Json.JsonSerializer.Serialize(new[]
{
LogtoParameters.Authentication.Identifiers.Username,
LogtoParameters.Authentication.Identifiers.Email,
}));

var directSignIn = new LogtoParameters.Authentication.DirectSignIn
Expand Down
3 changes: 1 addition & 2 deletions samples/sample-mvc/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public IActionResult SignIn()
/// <see cref="LogtoParameters.Authentication.FirstScreen"/>
authProperties.SetParameter("first_screen", LogtoParameters.Authentication.FirstScreen.Register);

// This parameter MUST be used together with `first_screen`.
authProperties.SetParameter("identifiers", string.Join(",", new[]
authProperties.SetParameter("identifiers", JsonSerializer.Serialize(new[]
{
LogtoParameters.Authentication.Identifiers.Username,
}));
Expand Down
3 changes: 1 addition & 2 deletions samples/sample/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public async Task OnPostSignInAsync()
/// <see cref="LogtoParameters.Authentication.FirstScreen"/>
authProperties.SetParameter("first_screen", LogtoParameters.Authentication.FirstScreen.Register);

// This parameter MUST be used together with `first_screen`
authProperties.SetParameter("identifiers", string.Join(",", new[]
authProperties.SetParameter("identifiers", JsonSerializer.Serialize(new[]
{
LogtoParameters.Authentication.Identifiers.Username,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ private static void ConfigureOpenIdConnectOptions(OpenIdConnectOptions options,

if (context.Properties.Parameters.TryGetValue("identifiers", out var identifiers))
{
context.ProtocolMessage.Parameters.Add("identifiers", identifiers?.ToString());
var identifierArray = System.Text.Json.JsonSerializer.Deserialize<string[]>(
identifiers?.ToString() ?? "[]"
);
if (identifierArray?.Length > 0)
{
context.ProtocolMessage.Parameters.Add("identifier", string.Join(" ", identifierArray));
}
}

if (context.Properties.Parameters.TryGetValue("direct_sign_in", out var directSignIn))
Expand Down
Loading