From d9912e83dd9d74d32fa9c9546e31857a02b432ee Mon Sep 17 00:00:00 2001 From: Myra The Avali Date: Wed, 30 Sep 2026 15:19:52 +0200 Subject: [PATCH 1/2] Disable launcher reset password. The signup and resend confirmation where disabled because of the spam risk of sending emails without a captcha. This also sends an email and is problematic IMO. --- SS14.Auth/Controllers/AuthApiController.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SS14.Auth/Controllers/AuthApiController.cs b/SS14.Auth/Controllers/AuthApiController.cs index f079d390..522a48c9 100644 --- a/SS14.Auth/Controllers/AuthApiController.cs +++ b/SS14.Auth/Controllers/AuthApiController.cs @@ -113,22 +113,22 @@ public async Task Authenticate(AuthenticateRequest request) new[] { "" }, AuthenticateDenyResponseCode.TfaRequired)); } - + var verify = await _userManager.VerifyTwoFactorTokenAsync( - user, + user, _userManager.Options.Tokens.AuthenticatorTokenProvider, request.TfaCode); - + if (!verify) { return Unauthorized(new AuthenticateDenyResponse( new[] { "" }, AuthenticateDenyResponseCode.TfaInvalid)); } - + // 2FA passed, we're good. } - + var (token, expireTime) = await _sessionManager.RegisterNewSession(user, SessionManager.DefaultExpireTime); @@ -164,6 +164,8 @@ public async Task Register(RegisterRequest request) } */ + // Launcher reset password confirmation disabled due to spam risk. + /* [HttpPost("resetPassword")] public async Task ResetPassword(ResetPasswordRequest request) { @@ -184,6 +186,7 @@ public async Task ResetPassword(ResetPasswordRequest request) return Ok(); } + */ // Launcher resend confirmation disabled due to spam risk. /* @@ -317,4 +320,4 @@ public enum RegisterResponseStatus { Registered, RegisteredNeedConfirmation -} \ No newline at end of file +} From fafa1f566369b795c1259eeab445e60bb299781d Mon Sep 17 00:00:00 2001 From: Myra The Avali Date: Wed, 30 Sep 2026 15:37:50 +0200 Subject: [PATCH 2/2] Add captcha (requires #40) --- .../Identity/Pages/Account/ForgotPassword.cshtml | 2 ++ .../Identity/Pages/Account/ForgotPassword.cshtml.cs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml b/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml index b911471c..0b8b1c10 100644 --- a/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml +++ b/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml @@ -17,6 +17,7 @@ + @@ -24,4 +25,5 @@ @section Scripts { + } diff --git a/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs b/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs index 4b1984ad..adf4a90d 100644 --- a/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs +++ b/SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs @@ -9,6 +9,7 @@ using SS14.Auth.Shared; using SS14.Auth.Shared.Data; using SS14.Auth.Shared.Emails; +using SS14.Web.Captcha; namespace SS14.Web.Areas.Identity.Pages.Account; @@ -17,16 +18,21 @@ public class ForgotPasswordModel : PageModel { private readonly UserManager _userManager; private readonly IEmailSender _emailSender; + private readonly CaptchaService _captcha; - public ForgotPasswordModel(UserManager userManager, IEmailSender emailSender) + public ForgotPasswordModel(UserManager userManager, IEmailSender emailSender, CaptchaService captcha) { _userManager = userManager; _emailSender = emailSender; + _captcha = captcha; } [BindProperty] public InputModel Input { get; set; } + [BindProperty(Name = "cf-turnstile-response")] + public string CaptchaResponse { get; set; } + public class InputModel { [Required] @@ -36,6 +42,9 @@ public class InputModel public async Task OnPostAsync() { + if (!await _captcha.ValidateCaptcha(CaptchaResponse, ModelState)) + return Page(); + if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(Input.Email); @@ -62,4 +71,4 @@ public async Task OnPostAsync() return Page(); } -} \ No newline at end of file +}