having to change password from authenticated access

vnext
Paul Schneider 6 years ago
parent 6de8082b2c
commit 7e7ba31b61
3 changed files with 16 additions and 3 deletions

@ -430,8 +430,13 @@ namespace Yavsc.Controllers
// GET: /Account/ForgotPassword
[HttpGet]
[AllowAnonymous]
public IActionResult ForgotPassword()
public async Task<IActionResult> ForgotPassword()
{
if (User.Identity.IsAuthenticated)
ViewBag.UserEmail = ( await _dbContext.Users.SingleAsync(
u => u.Id == User.GetUserId()
) ).Email;
return View();
}

@ -12,7 +12,13 @@
<div class="form-group">
<label class="col-md-2 control-label">@SR["LoginOrEmail"]</label>
<div class="col-md-10">
@if (User.Identity.IsAuthenticated) {
<input type="hidden" name="LoginOrEmail" value="@ViewBag.UserEmail" />
@ViewBag.UserEmail
} else {
<input asp-for="LoginOrEmail" class="form-control" />
}
<span asp-validation-for="LoginOrEmail" class="text-danger"></span>
</div>
</div>

@ -32,7 +32,9 @@
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button type="submit" class="btn btn-default">Change password</button>
<button type="submit" class="btn btn-default">@SR["Change password"]</button>
<a asp-action="ForgotPassword" asp-controller="Account">@SR["Forgot your password?"]</a>
</div>
</div>
</form>

Loading…