🐛 Fix PCKE state broke the callback

This commit is contained in:
2025-06-17 21:30:58 +08:00
parent 5e455599fd
commit 3aad515ab8
3 changed files with 22 additions and 22 deletions

View File

@ -22,7 +22,7 @@ public class OidcController(
private static readonly TimeSpan StateExpiration = TimeSpan.FromMinutes(15);
[HttpGet("{provider}")]
public async Task<ActionResult> SignIn([FromRoute] string provider, [FromQuery] string? returnUrl = "/")
public async Task<ActionResult> OidcLogin([FromRoute] string provider, [FromQuery] string? returnUrl = "/")
{
try
{
@ -42,13 +42,12 @@ public class OidcController(
var authUrl = oidcService.GetAuthorizationUrl(state, nonce);
return Redirect(authUrl);
}
else // Otherwise, proceed with login/registration flow
else // Otherwise, proceed with the login / registration flow
{
var state = returnUrl;
var nonce = Guid.NewGuid().ToString();
// The state parameter is the returnUrl. The callback will not find a session state and will treat it as a login.
var authUrl = oidcService.GetAuthorizationUrl(state ?? "/", nonce);
var authUrl = oidcService.GetAuthorizationUrl(returnUrl ?? "/", nonce);
return Redirect(authUrl);
}
}