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

success/error messages for admin

This commit is contained in:
Kyle Spearrin
2018-03-28 10:38:01 -04:00
parent 674077d453
commit 40dff2cd6e
6 changed files with 41 additions and 8 deletions

View File

@@ -7,7 +7,6 @@ using Bit.Core;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using System.Linq;
namespace Bit.Admin.Controllers
{

View File

@@ -16,11 +16,19 @@ namespace Bit.Admin.Controllers
_signInManager = signInManager;
}
public IActionResult Index(string returnUrl = null)
public IActionResult Index(string returnUrl = null, string error = null, string success = null,
bool accessDenied = false)
{
if(string.IsNullOrWhiteSpace(error) && accessDenied)
{
error = "Access denied. Please log in.";
}
return View(new LoginModel
{
ReturnUrl = returnUrl
ReturnUrl = returnUrl,
Error = error,
Success = success
});
}
@@ -32,7 +40,11 @@ namespace Bit.Admin.Controllers
{
await _signInManager.PasswordlessSignInAsync(model.Email,
Url.Action("Confirm", "Login", new { returnUrl = model.ReturnUrl }, Request.Scheme));
return RedirectToAction("Index", "Home");
return RedirectToAction("Index", new
{
success = "If a valid admin user with this email address exists, " +
"we've sent you an email with a secure link to log in."
});
}
return View(model);
@@ -43,8 +55,10 @@ namespace Bit.Admin.Controllers
var result = await _signInManager.PasswordlessSignInAsync(email, token, true);
if(!result.Succeeded)
{
// TODO: error?
return RedirectToAction("Index");
return RedirectToAction("Index", new
{
error = "This login confirmation link is invalid. Try logging in again."
});
}
if(!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl))
@@ -60,7 +74,10 @@ namespace Bit.Admin.Controllers
public async Task<IActionResult> Logout()
{
await _signInManager.SignOutAsync();
return RedirectToAction("Index");
return RedirectToAction("Index", new
{
success = "You have been logged out."
});
}
}
}