Merge branch 'main' of https://git.azuze.fr/kawa/SharepointToolbox-Web
This commit is contained in:
@@ -3,28 +3,29 @@
|
||||
@inject IUserService UserService
|
||||
@inject IUserContextAccessor UserContext
|
||||
@inject IAuditService Audit
|
||||
@inject TranslationSource T
|
||||
@rendermode InteractiveServer
|
||||
@using SharepointToolbox.Web.Core.Models
|
||||
@using SharepointToolbox.Web.Services.Audit
|
||||
@using SharepointToolbox.Web.Services.Auth
|
||||
@using SharepointToolbox.Web.Services.Session
|
||||
|
||||
<h1 class="page-title">Change Password</h1>
|
||||
<h1 class="page-title">@T["changepw.title"]</h1>
|
||||
|
||||
@if (!UserContext.IsAuthenticated)
|
||||
{
|
||||
<div class="alert alert-error">You must be signed in.</div>
|
||||
<div class="alert alert-error">@T["changepw.mustsignin"]</div>
|
||||
return;
|
||||
}
|
||||
|
||||
@if (_user is null)
|
||||
{
|
||||
<p class="page-subtitle">Loading…</p>
|
||||
<p class="page-subtitle">@T["changepw.loading"]</p>
|
||||
}
|
||||
else if (_user.Provider != AuthProvider.Local)
|
||||
{
|
||||
<div class="alert alert-info">
|
||||
Your account signs in with Microsoft (Entra). Manage its password in your Microsoft account.
|
||||
@T["changepw.entra"]
|
||||
</div>
|
||||
}
|
||||
else
|
||||
@@ -34,17 +35,17 @@ else
|
||||
<div class="alert @(_isError ? "alert-error" : "alert-success")">@_message</div>
|
||||
}
|
||||
<div class="card" style="max-width:420px">
|
||||
<label class="form-label" for="cur">Current password</label>
|
||||
<label class="form-label" for="cur">@T["changepw.current"]</label>
|
||||
<input id="cur" class="form-input" type="password" @bind="_current" autocomplete="current-password" />
|
||||
|
||||
<label class="form-label" for="new" style="margin-top:12px">New password</label>
|
||||
<label class="form-label" for="new" style="margin-top:12px">@T["changepw.new"]</label>
|
||||
<input id="new" class="form-input" type="password" @bind="_new" autocomplete="new-password" />
|
||||
|
||||
<label class="form-label" for="confirm" style="margin-top:12px">Confirm new password</label>
|
||||
<label class="form-label" for="confirm" style="margin-top:12px">@T["changepw.confirm"]</label>
|
||||
<input id="confirm" class="form-input" type="password" @bind="_confirm" autocomplete="new-password" />
|
||||
|
||||
<div style="margin-top:14px">
|
||||
<button class="btn btn-primary" @onclick="SubmitAsync">Change password</button>
|
||||
<button class="btn btn-primary" @onclick="SubmitAsync">@T["changepw.submit"]</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -68,7 +69,7 @@ else
|
||||
if (_user is null) return;
|
||||
if (string.IsNullOrWhiteSpace(_new) || _new != _confirm)
|
||||
{
|
||||
_message = "New passwords do not match.";
|
||||
_message = T["changepw.err.mismatch"];
|
||||
_isError = true;
|
||||
return;
|
||||
}
|
||||
@@ -78,13 +79,13 @@ else
|
||||
{
|
||||
await Audit.LogAsync("PasswordChanged", "", Array.Empty<string>(),
|
||||
$"Changed own password ({_user.Email}).");
|
||||
_message = "Password changed.";
|
||||
_message = T["changepw.success"];
|
||||
_isError = false;
|
||||
_current = _new = _confirm = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
_message = "Current password is incorrect.";
|
||||
_message = T["changepw.err.incorrect"];
|
||||
_isError = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user