diff --git a/Moonlight/App/Models/Forms/NameModel.cs b/Moonlight/App/Models/Forms/NameModel.cs new file mode 100644 index 00000000..17d832ab --- /dev/null +++ b/Moonlight/App/Models/Forms/NameModel.cs @@ -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; } +} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/PasswordModel.cs b/Moonlight/App/Models/Forms/PasswordModel.cs new file mode 100644 index 00000000..237f6a43 --- /dev/null +++ b/Moonlight/App/Models/Forms/PasswordModel.cs @@ -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; } +} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/UserStatus.cs b/Moonlight/App/Models/Misc/UserStatus.cs index 22bf70c6..a270ead5 100644 --- a/Moonlight/App/Models/Misc/UserStatus.cs +++ b/Moonlight/App/Models/Misc/UserStatus.cs @@ -9,5 +9,6 @@ public enum UserStatus Warned, Banned, Disabled, - DataPending + DataPending, + PasswordPending } \ No newline at end of file diff --git a/Moonlight/Shared/Components/Auth/PasswordChangeView.razor b/Moonlight/Shared/Components/Auth/PasswordChangeView.razor new file mode 100644 index 00000000..f57d1aa7 --- /dev/null +++ b/Moonlight/Shared/Components/Auth/PasswordChangeView.razor @@ -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 + +
+
+
+
+ + +
+

+ Change your password +

+
+ You need to change your password in order to use moonlight +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+
+
+
+ +@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); + } +} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Auth/UserDataSetView.razor b/Moonlight/Shared/Components/Auth/UserDataSetView.razor new file mode 100644 index 00000000..d1191ec1 --- /dev/null +++ b/Moonlight/Shared/Components/Auth/UserDataSetView.razor @@ -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 + +
+
+
+
+ + +
+

+ Enter your information +

+
+ You need to enter your full name in order to use moonlight +
+
+ +
+
+ +
+ +
+ +
+
+ + +
+
+
+
+
+
+ +@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); + } +} \ No newline at end of file diff --git a/Moonlight/Shared/Layouts/MainLayout.razor b/Moonlight/Shared/Layouts/MainLayout.razor index b2de0364..5345b49a 100644 --- a/Moonlight/Shared/Layouts/MainLayout.razor +++ b/Moonlight/Shared/Layouts/MainLayout.razor @@ -79,6 +79,14 @@ { } + else if (User.Status == UserStatus.PasswordPending) + { + + } + else if (User.Status == UserStatus.DataPending) + { + + } else { @Body diff --git a/Moonlight/resources/lang/de_de.lang b/Moonlight/resources/lang/de_de.lang index 0cfc0d21..02ca6ef0 100644 --- a/Moonlight/resources/lang/de_de.lang +++ b/Moonlight/resources/lang/de_de.lang @@ -462,3 +462,8 @@ Create subscription;Create subscription Options;Options Amount;Amount 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'. diff --git a/Moonlight/resources/mail/passwordChange.html b/Moonlight/resources/mail/passwordChange.html new file mode 100644 index 00000000..ae3e5a12 --- /dev/null +++ b/Moonlight/resources/mail/passwordChange.html @@ -0,0 +1,53 @@ + + + + + Moonlight password change + + +
+ + + + + + + + + + + + +
+
+
+ + Logo + +
+
+

Hey {{FirstName}}, your password has been changed

+

If this was not you please contact us. Also here is the data we collected.

+

IP: {{Ip}}

+

Device: {{Device}}

+

Location: {{Location}}

+
+ Open Moonlight + +
+
+

You need help?

+

We are happy to help!

+

More information at + endelon.link/support. +

+
+

Copyright 2023 Endelon Hosting

+
+
+ + \ No newline at end of file