Merge pull request #28 from Moonlight-Panel/ForcePasswordChange
Force password change
This commit is contained in:
14
Moonlight/App/Models/Forms/NameModel.cs
Normal file
14
Moonlight/App/Models/Forms/NameModel.cs
Normal 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; }
|
||||||
|
}
|
||||||
10
Moonlight/App/Models/Forms/PasswordModel.cs
Normal file
10
Moonlight/App/Models/Forms/PasswordModel.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Moonlight.App.Models.Forms;
|
||||||
|
|
||||||
|
public class PasswordModel
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "You need to enter a password")]
|
||||||
|
[MinLength(8, ErrorMessage = "You need to enter a password with minimum 8 characters in lenght")]
|
||||||
|
public string Password { get; set; }
|
||||||
|
}
|
||||||
@@ -9,5 +9,6 @@ public enum UserStatus
|
|||||||
Warned,
|
Warned,
|
||||||
Banned,
|
Banned,
|
||||||
Disabled,
|
Disabled,
|
||||||
DataPending
|
DataPending,
|
||||||
|
PasswordPending
|
||||||
}
|
}
|
||||||
64
Moonlight/Shared/Components/Auth/PasswordChangeView.razor
Normal file
64
Moonlight/Shared/Components/Auth/PasswordChangeView.razor
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
67
Moonlight/Shared/Components/Auth/UserDataSetView.razor
Normal file
67
Moonlight/Shared/Components/Auth/UserDataSetView.razor
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -79,6 +79,14 @@
|
|||||||
{
|
{
|
||||||
<DisabledAlert></DisabledAlert>
|
<DisabledAlert></DisabledAlert>
|
||||||
}
|
}
|
||||||
|
else if (User.Status == UserStatus.PasswordPending)
|
||||||
|
{
|
||||||
|
<PasswordChangeView></PasswordChangeView>
|
||||||
|
}
|
||||||
|
else if (User.Status == UserStatus.DataPending)
|
||||||
|
{
|
||||||
|
<UserDataSetView></UserDataSetView>
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@Body
|
@Body
|
||||||
|
|||||||
@@ -462,3 +462,8 @@ Create subscription;Create subscription
|
|||||||
Options;Options
|
Options;Options
|
||||||
Amount;Amount
|
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
|
||||||
|
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'.
|
||||||
|
|||||||
53
Moonlight/resources/mail/passwordChange.html
Normal file
53
Moonlight/resources/mail/passwordChange.html
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Moonlight password change</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="background-color:#ffffff; padding: 45px 0 34px 0; border-radius: 24px; margin:40px auto; max-width: 600px;">
|
||||||
|
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" height="auto"
|
||||||
|
style="border-collapse:collapse">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td align="center" valign="center" style="text-align:center; padding-bottom: 10px">
|
||||||
|
<div style="text-align:center; margin:0 15px 34px 15px">
|
||||||
|
<div style="margin-bottom: 10px">
|
||||||
|
<a href="https://endelon-hosting.de" rel="noopener" target="_blank">
|
||||||
|
<img alt="Logo" src="https://moonlight.endelon-hosting.de/assets/media/logo/MoonFullText.png" style="height: 35px">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div style="font-size: 14px; font-weight: 500; margin-bottom: 27px; font-family:Arial,Helvetica,sans-serif;">
|
||||||
|
<p style="margin-bottom:9px; color:#181C32; font-size: 22px; font-weight:700">Hey {{FirstName}}, your password has been changed</p>
|
||||||
|
<p style="margin-bottom:2px; color:#7E8299">If this was not you please contact us. Also here is the data we collected.</p>
|
||||||
|
<p style="margin-bottom:2px; color:#7E8299">IP: {{Ip}}</p>
|
||||||
|
<p style="margin-bottom:2px; color:#7E8299">Device: {{Device}}</p>
|
||||||
|
<p style="margin-bottom:2px; color:#7E8299">Location: {{Location}}</p>
|
||||||
|
</div>
|
||||||
|
<a href="https://moonlight.endelon-hosting.de" target="_blank"
|
||||||
|
style="background-color:#50cd89; border-radius:6px;display:inline-block; padding:11px 19px; color: #FFFFFF; font-size: 14px; font-weight:500;">Open Moonlight
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" valign="center"
|
||||||
|
style="font-size: 13px; text-align:center; padding: 0 10px 10px 10px; font-weight: 500; color: #A1A5B7; font-family:Arial,Helvetica,sans-serif">
|
||||||
|
<p style="color:#181C32; font-size: 16px; font-weight: 600; margin-bottom:9px">You need help?</p>
|
||||||
|
<p style="margin-bottom:2px">We are happy to help!</p>
|
||||||
|
<p style="margin-bottom:4px">More information at
|
||||||
|
<a href="https://endelon.link/support" rel="noopener" target="_blank" style="font-weight: 600">endelon.link/support</a>.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" valign="center"
|
||||||
|
style="font-size: 13px; padding:0 15px; text-align:center; font-weight: 500; color: #A1A5B7;font-family:Arial,Helvetica,sans-serif">
|
||||||
|
<p>Copyright 2023 Endelon Hosting </p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user