mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
POS: Option for user sign in via the QR code (#6231)
* Login Code: Turn into Blazor component and extend with data for the app * POS: Add login code for POS frontend * Improve components, fix test
This commit is contained in:
@@ -123,15 +123,30 @@ namespace BTCPayServer.Controllers
|
||||
return View(nameof(Login), new LoginViewModel { Email = email });
|
||||
}
|
||||
|
||||
// GET is for signin via the POS backend
|
||||
[HttpGet("/login/code")]
|
||||
[AllowAnonymous]
|
||||
[RateLimitsFilter(ZoneLimits.Login, Scope = RateLimitsScope.RemoteAddress)]
|
||||
public async Task<IActionResult> LoginUsingCode(string loginCode, string returnUrl = null)
|
||||
{
|
||||
return await LoginCodeResult(loginCode, returnUrl);
|
||||
}
|
||||
|
||||
[HttpPost("/login/code")]
|
||||
[AllowAnonymous]
|
||||
[ValidateAntiForgeryToken]
|
||||
[RateLimitsFilter(ZoneLimits.Login, Scope = RateLimitsScope.RemoteAddress)]
|
||||
public async Task<IActionResult> LoginWithCode(string loginCode, string returnUrl = null)
|
||||
{
|
||||
return await LoginCodeResult(loginCode, returnUrl);
|
||||
}
|
||||
|
||||
private async Task<IActionResult> LoginCodeResult(string loginCode, string returnUrl)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(loginCode))
|
||||
{
|
||||
var userId = _userLoginCodeService.Verify(loginCode);
|
||||
var code = loginCode.Split(';').First();
|
||||
var userId = _userLoginCodeService.Verify(code);
|
||||
if (userId is null)
|
||||
{
|
||||
TempData[WellKnownTempData.ErrorMessage] = "Login code was invalid";
|
||||
|
||||
Reference in New Issue
Block a user