Skip to content
Merged
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
15 changes: 9 additions & 6 deletions SS14.Auth/Controllers/AuthApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@ public async Task<IActionResult> 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);

Expand Down Expand Up @@ -164,6 +164,8 @@ public async Task<IActionResult> Register(RegisterRequest request)
}
*/

// Launcher reset password confirmation disabled due to spam risk.
/*
[HttpPost("resetPassword")]
public async Task<IActionResult> ResetPassword(ResetPasswordRequest request)
{
Expand All @@ -184,6 +186,7 @@ public async Task<IActionResult> ResetPassword(ResetPasswordRequest request)

return Ok();
}
*/

// Launcher resend confirmation disabled due to spam risk.
/*
Expand Down Expand Up @@ -317,4 +320,4 @@ public enum RegisterResponseStatus
{
Registered,
RegisteredNeedConfirmation
}
}
2 changes: 2 additions & 0 deletions SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
<input asp-for="Input.Email" class="form-control" />
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<partial name="Captcha"/>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>

@section Scripts {
<partial name="_ValidationScriptsPartial" />
<partial name="_CaptchaScripts"/>
}
13 changes: 11 additions & 2 deletions SS14.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,16 +18,21 @@ public class ForgotPasswordModel : PageModel
{
private readonly UserManager<SpaceUser> _userManager;
private readonly IEmailSender _emailSender;
private readonly CaptchaService _captcha;

public ForgotPasswordModel(UserManager<SpaceUser> userManager, IEmailSender emailSender)
public ForgotPasswordModel(UserManager<SpaceUser> 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]
Expand All @@ -36,6 +42,9 @@ public class InputModel

public async Task<IActionResult> OnPostAsync()
{
if (!await _captcha.ValidateCaptcha(CaptchaResponse, ModelState))
return Page();

if (ModelState.IsValid)
{
var user = await _userManager.FindByEmailAsync(Input.Email);
Expand All @@ -62,4 +71,4 @@ public async Task<IActionResult> OnPostAsync()

return Page();
}
}
}
Loading