验证码优化
This commit is contained in:
1 parent
f489a3553c
commit
4a3bb84aa4
17 files changed
+156
-430
No files matched your search
@@ -12,6 +12,7 @@ using Microsoft.AspNetCore.RateLimiting;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Lazy.Captcha.Core;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
|
||||
namespace Jiaowu.Api.Controllers;
|
||||
@@ -22,7 +23,7 @@ public sealed class SsoController(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
IAuthSessionService authSessionService,
|
||||
IDistributedCache cache,
|
||||
ILoginCaptchaService loginCaptcha,
|
||||
ICaptcha captcha,
|
||||
IOptions<SsoOptions> options,
|
||||
ILogger<SsoController> logger) : ControllerBase
|
||||
{
|
||||
@@ -47,8 +48,8 @@ public sealed class SsoController(
|
||||
[FromQuery] string? bindingIntent = null,
|
||||
[FromQuery] bool nativeApp = false,
|
||||
[FromQuery] string? nativeState = null,
|
||||
[FromQuery] string? captchaTicket = null,
|
||||
[FromQuery] string? deviceId = null,
|
||||
[FromQuery] string? captchaId = null,
|
||||
[FromQuery] string? captchaCode = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!_options.Enabled)
|
||||
@@ -56,8 +57,9 @@ public sealed class SsoController(
|
||||
|
||||
var safeReturnUrl = NormalizeReturnUrl(returnUrl);
|
||||
if (string.IsNullOrWhiteSpace(bindingIntent) &&
|
||||
(string.IsNullOrWhiteSpace(captchaTicket) ||
|
||||
!await loginCaptcha.ConsumeProofAsync(captchaTicket, deviceId, HttpContext, cancellationToken)))
|
||||
(string.IsNullOrWhiteSpace(captchaId) ||
|
||||
string.IsNullOrWhiteSpace(captchaCode) ||
|
||||
!captcha.Validate(captchaId, captchaCode)))
|
||||
{
|
||||
return Unauthorized(AuthController.LoginCaptchaProblem());
|
||||
}
|
||||
@@ -417,8 +419,8 @@ public sealed class SsoController(
|
||||
bindingIntent = intentCode,
|
||||
nativeApp,
|
||||
nativeState,
|
||||
captchaTicket = (string?)null,
|
||||
deviceId = (string?)null
|
||||
captchaId = (string?)null,
|
||||
captchaCode = (string?)null
|
||||
})!;
|
||||
return new SsoBindingStartResponse(loginUrl);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user