mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
respect return url on sign in link
This commit is contained in:
@ -16,9 +16,12 @@ namespace Bit.Admin.Controllers
|
||||
_signInManager = signInManager;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
public IActionResult Index(string returnUrl = null)
|
||||
{
|
||||
return View();
|
||||
return View(new LoginModel
|
||||
{
|
||||
ReturnUrl = returnUrl
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -28,19 +31,25 @@ namespace Bit.Admin.Controllers
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
await _signInManager.PasswordlessSignInAsync(model.Email,
|
||||
Url.Action("Confirm", "Login", null, Request.Scheme));
|
||||
Url.Action("Confirm", "Login", new { returnUrl = model.ReturnUrl }, Request.Scheme));
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Confirm(string email, string token)
|
||||
public async Task<IActionResult> Confirm(string email, string token, string returnUrl)
|
||||
{
|
||||
var result = await _signInManager.PasswordlessSignInAsync(email, token, false);
|
||||
if(!result.Succeeded)
|
||||
{
|
||||
return View("Error");
|
||||
// TODO: error?
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl))
|
||||
{
|
||||
return Redirect(returnUrl);
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
|
@ -7,5 +7,6 @@ namespace Bit.Admin.Models
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
public string Email { get; set; }
|
||||
public string ReturnUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
<div class="card-body">
|
||||
<p>Please enter your email address below to log in.</p>
|
||||
<form asp-action="" method="post">
|
||||
<input type="hidden" asp-for="ReturnUrl" />
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Email" class="sr-only">Email Address</label>
|
||||
|
Reference in New Issue
Block a user