So my users should still login using their email adress, but I want my top menu to greet them by their Name. I have the name implemented and everything, I just need a way of getting it to show.
Currently I have this in my top menu.
Logged in as @User.Identity.Name
This gives me AppUser.EmailAddress, but i need the AppUser.Name
This is my Login action, currently it only contains data from the loginviewmodel (email, password, rememberme).
public async Task<IActionResult> Login(LoginViewModel login, string returnUrl = null)
{
if (!ModelState.IsValid)
{
return View(login);
}
var result = await _signInManager.PasswordSignInAsync(
login.EmailAddress,
login.Password,
login.RememberMe, false);
if (!result.Succeeded)
{
ViewBag.Succeeded = false;
return View(login);
}
if (string.IsNullOrWhiteSpace(returnUrl))
{
return RedirectToAction("Index", "Home");
}
return Redirect(returnUrl);
The name exists in my AppUser class and my RegisterViewModel which is used by the register action.
I'm using Identity 3.0.0 but I welcome ways of solving it on other versions,