mirror of
https://github.com/bitwarden/server.git
synced 2025-04-07 14:08:13 -05:00
use message codes in query string (#681)
This commit is contained in:
parent
0422436287
commit
fef512bad1
@ -16,19 +16,19 @@ namespace Bit.Admin.Controllers
|
|||||||
_signInManager = signInManager;
|
_signInManager = signInManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index(string returnUrl = null, string error = null, string success = null,
|
public IActionResult Index(string returnUrl = null, int? error = null, int? success = null,
|
||||||
bool accessDenied = false)
|
bool accessDenied = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(error) && accessDenied)
|
if (!error.HasValue && accessDenied)
|
||||||
{
|
{
|
||||||
error = "Access denied. Please log in.";
|
error = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return View(new LoginModel
|
return View(new LoginModel
|
||||||
{
|
{
|
||||||
ReturnUrl = returnUrl,
|
ReturnUrl = returnUrl,
|
||||||
Error = error,
|
Error = GetMessage(error),
|
||||||
Success = success
|
Success = GetMessage(success)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +41,7 @@ namespace Bit.Admin.Controllers
|
|||||||
await _signInManager.PasswordlessSignInAsync(model.Email, model.ReturnUrl);
|
await _signInManager.PasswordlessSignInAsync(model.Email, model.ReturnUrl);
|
||||||
return RedirectToAction("Index", new
|
return RedirectToAction("Index", new
|
||||||
{
|
{
|
||||||
success = "If a valid admin user with this email address exists, " +
|
success = 3
|
||||||
"we've sent you an email with a secure link to log in."
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ namespace Bit.Admin.Controllers
|
|||||||
{
|
{
|
||||||
return RedirectToAction("Index", new
|
return RedirectToAction("Index", new
|
||||||
{
|
{
|
||||||
error = "This login confirmation link is invalid. Try logging in again."
|
error = 2
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +74,21 @@ namespace Bit.Admin.Controllers
|
|||||||
await _signInManager.SignOutAsync();
|
await _signInManager.SignOutAsync();
|
||||||
return RedirectToAction("Index", new
|
return RedirectToAction("Index", new
|
||||||
{
|
{
|
||||||
success = "You have been logged out."
|
success = 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetMessage(int? messageCode)
|
||||||
|
{
|
||||||
|
return messageCode switch
|
||||||
|
{
|
||||||
|
1 => "You have been logged out.",
|
||||||
|
2 => "This login confirmation link is invalid. Try logging in again.",
|
||||||
|
3 => "If a valid admin user with this email address exists, " +
|
||||||
|
"we've sent you an email with a secure link to log in.",
|
||||||
|
4 => "Access denied. Please log in.",
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user