1
0
mirror of https://github.com/bitwarden/server synced 2025-12-21 10:43:44 +00:00

respect return url on sign in link

This commit is contained in:
Kyle Spearrin
2018-03-22 13:18:18 -04:00
parent ff9f605b7d
commit 14039d7d1a
6 changed files with 57 additions and 9 deletions

View File

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