require name before use (--> user status 7)

This commit is contained in:
Daniel Balk
2023-04-03 21:22:54 +02:00
parent 5d8796299c
commit 49e75c5a8d
4 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.App.Models.Forms;
public class NameModel
{
[Required]
[MinLength(2, ErrorMessage = "Do you think, that works?")]
public string FirstName { get; set; }
[Required]
[MinLength(2, ErrorMessage = "Do you think, that works?")]
public string LastName { get; set; }
}

View File

@@ -0,0 +1,67 @@
@using Microsoft.AspNetCore.Components
@using Moonlight.App.Database.Entities
@using Moonlight.App.Models.Forms
@using Moonlight.App.Models.Misc
@using Moonlight.App.Repositories
@using Moonlight.App.Services
@using Moonlight.App.Services.Sessions
@inject IdentityService IdentityService
@inject UserRepository UserRepository
@inject SmartTranslateService SmartTranslateService
@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="Name" OnValidSubmit="SetName">
<div class="text-center mt-3 mb-11">
<h1 class="text-dark fw-bolder mb-3">
<TL>Enter your information</TL>
</h1>
<div class="text-gray-500 fw-semibold fs-6">
<TL>You need to enter your full name in order to use moonlight</TL>
</div>
</div>
<div class="row g-3">
<div class="col">
<InputText @bind-Value="Name.FirstName" type="text" placeholder="@(SmartTranslateService.Translate("First name"))" class="form-control bg-transparent"/>
</div>
<div class="col">
<InputText @bind-Value="Name.LastName" type="text" placeholder="@(SmartTranslateService.Translate("Last name"))" class="form-control bg-transparent"/>
</div>
</div>
<button type="submit" class="btn btn-primary float-end mt-3">
<TL>Change</TL>
</button>
</SmartForm>
</LazyLoader>
</div>
</div>
</div>
</div>
@code {
private User User;
private NameModel Name = new ();
private async Task Load(LazyLoader loader)
{
User = await IdentityService.Get();
}
private async Task SetName()
{
User.FirstName = Name.FirstName;
User.LastName = Name.LastName;
User.Status = UserStatus.Unverified;
UserRepository.Update(User);
NavigationManager.NavigateTo(NavigationManager.Uri, true);
}
}

View File

@@ -83,6 +83,10 @@
{ {
<PasswordChangeView></PasswordChangeView> <PasswordChangeView></PasswordChangeView>
} }
else if (User.Status == UserStatus.DataPending)
{
<UserDataSetView></UserDataSetView>
}
else else
{ {
@Body @Body

View File

@@ -464,3 +464,6 @@ Amount;Amount
Do you really want to delete it?;Do you really want to delete it? Do you really want to delete it?;Do you really want to delete it?
Change your password;Change your password Change your password;Change your password
You need to change your password in order to use moonlight;You need to change your password in order to use moonlight You need to change your password in order to use moonlight;You need to change your password in order to use moonlight
You need to enter your full name in order to use moonlight;You need to enter your full name in order to use moonlight
Enter your information;Enter your information
The field FirstName must be a string or array type with a minimum length of '2'.;The field FirstName must be a string or array type with a minimum length of '2'.