force password change after login

This commit is contained in:
Daniel Balk
2023-04-03 21:07:55 +02:00
parent 17a465c553
commit 5d8796299c
6 changed files with 135 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
@using Moonlight.App.Services
@using Moonlight.App.Models.Forms
@using Moonlight.App.Services.Sessions
@using Moonlight.App.Database.Entities
@using Moonlight.App.Models.Misc
@using Moonlight.App.Repositories
@inject SmartTranslateService SmartTranslateService
@inject IdentityService IdentityService
@inject UserService UserService
@inject UserRepository UserRepository
@inject NavigationManager NavigationManager
<div class="d-flex flex-center">
<div class="card rounded-3 w-md-550px">
<div class="card-body">
<div class="d-flex flex-center flex-column-fluid">
<LazyLoader Load="Load">
<SmartForm Model="Password" OnValidSubmit="DoChange">
<div class="text-center mt-3 mb-11">
<h1 class="text-dark fw-bolder mb-3">
<TL>Change your password</TL>
</h1>
<div class="text-gray-500 fw-semibold fs-6">
<TL>You need to change your password in order to use moonlight</TL>
</div>
</div>
<div class="row g-3 mb-9">
<div class="col-md-9">
<InputText @bind-Value="Password.Password" type="password" placeholder="@(SmartTranslateService.Translate("New password"))" class="form-control bg-transparent"/>
</div>
<div class="col">
<button type="submit" class="btn btn-primary float-end">
<TL>Change</TL>
</button>
</div>
</div>
</SmartForm>
</LazyLoader>
</div>
</div>
</div>
</div>
@code {
private PasswordModel Password = new();
private User User;
private async Task Load(LazyLoader loader)
{
User = await IdentityService.Get();
}
private async Task DoChange()
{
await UserService.ChangePassword(User, Password.Password);
User.Status = UserStatus.Unverified;
UserRepository.Update(User);
NavigationManager.NavigateTo(NavigationManager.Uri, true);
}
}