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:
d11n
2024-09-26 12:10:14 +02:00
committed by GitHub
parent b5590a38fe
commit 272cc3d3c9
14 changed files with 253 additions and 75 deletions

View File

@@ -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";