Merge pull request #15 from Moonlight-Panel/CleanupAndFixes
Added form proccessing screen (not finished). Some ui changes. User m…
This commit is contained in:
@@ -19,12 +19,12 @@ public class User
|
|||||||
[MaxLength(64, ErrorMessage = "Max lenght reached")]
|
[MaxLength(64, ErrorMessage = "Max lenght reached")]
|
||||||
public string LastName { get; set; } = "";
|
public string LastName { get; set; } = "";
|
||||||
|
|
||||||
[Required]
|
[Required(ErrorMessage = "You need to enter an email address")]
|
||||||
[RegularExpression(@"^((((([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)[;]?)+$",
|
[EmailAddress(ErrorMessage = "You need to enter a valid email address")]
|
||||||
ErrorMessage = "Must be a valid email")]
|
|
||||||
[MaxLength(128, ErrorMessage = "Max lenght reached")]
|
|
||||||
public string Email { get; set; } = "";
|
public string Email { get; set; } = "";
|
||||||
|
|
||||||
|
[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; } = "";
|
public string Password { get; set; } = "";
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services
|
||||||
@using Moonlight.App.Exceptions
|
@using Moonlight.App.Exceptions
|
||||||
@using Logging.Net
|
@using Logging.Net
|
||||||
|
@using Moonlight.App.Database.Entities
|
||||||
@using Moonlight.App.Services.OAuth2
|
@using Moonlight.App.Services.OAuth2
|
||||||
@using Moonlight.App.Services.Sessions
|
@using Moonlight.App.Services.Sessions
|
||||||
|
|
||||||
@@ -24,10 +25,10 @@
|
|||||||
<div class="card rounded-3 w-md-550px">
|
<div class="card rounded-3 w-md-550px">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex flex-center flex-column-fluid pb-15 pb-lg-20">
|
<div class="d-flex flex-center flex-column-fluid pb-15 pb-lg-20">
|
||||||
<div class="form w-100 fv-plugins-bootstrap5 fv-plugins-framework" novalidate="novalidate">
|
<SmartForm Model="User" OnValidSubmit="DoLogin">
|
||||||
@if (!TotpRequired)
|
@if (!TotpRequired)
|
||||||
{
|
{
|
||||||
<div class="text-center mb-11">
|
<div class="text-center mt-3 mb-11">
|
||||||
<h1 class="text-dark fw-bolder mb-3">
|
<h1 class="text-dark fw-bolder mb-3">
|
||||||
<TL>Sign In</TL>
|
<TL>Sign In</TL>
|
||||||
</h1>
|
</h1>
|
||||||
@@ -61,12 +62,12 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fv-row mb-8 fv-plugins-icon-container">
|
<div class="mt-3 mb-3">
|
||||||
<input @bind="Email" type="text" placeholder="@(SmartTranslateService.Translate("Email"))" class="form-control bg-transparent">
|
<InputText @bind-Value="User.Email" type="email" placeholder="@(SmartTranslateService.Translate("Email"))" class="form-control bg-transparent"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fv-row mb-3 fv-plugins-icon-container">
|
<div class="mb-3">
|
||||||
<input @bind="Password" type="password" placeholder="@(SmartTranslateService.Translate("Password"))" class="form-control bg-transparent">
|
<InputText @bind-Value="User.Password" type="password" placeholder="@(SmartTranslateService.Translate("Password"))" class="form-control bg-transparent"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex flex-stack flex-wrap gap-3 fs-base fw-semibold mb-8">
|
<div class="d-flex flex-stack flex-wrap gap-3 fs-base fw-semibold mb-8">
|
||||||
@@ -78,11 +79,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-grid mb-10">
|
<div class="d-grid mb-10">
|
||||||
<WButton Text="@(SmartTranslateService.Translate("Sign-in"))"
|
<button type="submit" class="btn btn-primary">
|
||||||
WorkingText="@(SmartTranslateService.Translate("Working"))"
|
<TL>Sign-in</TL>
|
||||||
CssClasses="btn-primary"
|
</button>
|
||||||
OnClick="DoLogin">
|
|
||||||
</WButton>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -106,7 +105,7 @@
|
|||||||
<TL>Sign up</TL>
|
<TL>Sign up</TL>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</SmartForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -114,8 +113,7 @@
|
|||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
private string Email = "";
|
private User User = new();
|
||||||
private string Password = "";
|
|
||||||
|
|
||||||
private bool TotpRequired = false;
|
private bool TotpRequired = false;
|
||||||
private string TotpCode = "";
|
private string TotpCode = "";
|
||||||
@@ -124,16 +122,16 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Email = Email.ToLower().Trim();
|
User.Email = User.Email.ToLower().Trim();
|
||||||
|
|
||||||
TotpRequired = await UserService.CheckTotp(Email, Password);
|
TotpRequired = await UserService.CheckTotp(User.Email, User.Password);
|
||||||
|
|
||||||
if (!TotpRequired)
|
if (!TotpRequired)
|
||||||
{
|
{
|
||||||
var token = await UserService.Login(Email, Password);
|
var token = await UserService.Login(User.Email, User.Password);
|
||||||
await CookieService.SetValue("token", token, 10);
|
await CookieService.SetValue("token", token, 10);
|
||||||
|
|
||||||
if(NavigationManager.Uri.EndsWith("login"))
|
if (NavigationManager.Uri.EndsWith("login"))
|
||||||
NavigationManager.NavigateTo("/", true);
|
NavigationManager.NavigateTo("/", true);
|
||||||
else
|
else
|
||||||
NavigationManager.NavigateTo(NavigationManager.Uri, true);
|
NavigationManager.NavigateTo(NavigationManager.Uri, true);
|
||||||
@@ -167,7 +165,7 @@
|
|||||||
var url = await GoogleOAuth2Service.GetUrl();
|
var url = await GoogleOAuth2Service.GetUrl();
|
||||||
NavigationManager.NavigateTo(url, true);
|
NavigationManager.NavigateTo(url, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DoDiscord()
|
private async Task DoDiscord()
|
||||||
{
|
{
|
||||||
var url = await DiscordOAuth2Service.GetUrl();
|
var url = await DiscordOAuth2Service.GetUrl();
|
||||||
|
|||||||
@@ -3,17 +3,27 @@
|
|||||||
<div class="form">
|
<div class="form">
|
||||||
<EditForm @ref="EditForm" Model="Model" OnValidSubmit="ValidSubmit" OnInvalidSubmit="InvalidSubmit">
|
<EditForm @ref="EditForm" Model="Model" OnValidSubmit="ValidSubmit" OnInvalidSubmit="InvalidSubmit">
|
||||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||||
@if (ErrorMessages.Any())
|
@if (Working)
|
||||||
{
|
{
|
||||||
<div class="alert alert-danger p-10 mb-3">
|
<div class="d-flex flex-center flex-column">
|
||||||
@foreach (var msg in ErrorMessages)
|
<span class="fs-1 spinner-border spinner-border-lg align-middle me-2"></span>
|
||||||
{
|
<span class="mt-3 fs-5"><TL>Proccessing</TL></span>
|
||||||
<TL>@(msg)</TL>
|
|
||||||
<br/>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@(ChildContent)
|
else
|
||||||
|
{
|
||||||
|
if (ErrorMessages.Any())
|
||||||
|
{
|
||||||
|
<div class="alert alert-danger p-10 mb-3">
|
||||||
|
@foreach (var msg in ErrorMessages)
|
||||||
|
{
|
||||||
|
<TL>@(msg)</TL>
|
||||||
|
<br/>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@(ChildContent)
|
||||||
|
}
|
||||||
</EditForm>
|
</EditForm>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -21,16 +31,16 @@
|
|||||||
{
|
{
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public object Model { get; set; }
|
public object Model { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<EditContext> OnValidSubmit { get; set; }
|
public EventCallback<EditContext> OnValidSubmit { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<EditContext> OnInvalidSubmit { get; set; }
|
public EventCallback<EditContext> OnInvalidSubmit { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<EditContext> OnSubmit { get; set; }
|
public EventCallback<EditContext> OnSubmit { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public RenderFragment ChildContent { get; set; }
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
|
||||||
@@ -38,6 +48,8 @@
|
|||||||
|
|
||||||
private List<string> ErrorMessages = new();
|
private List<string> ErrorMessages = new();
|
||||||
|
|
||||||
|
private bool Working = false;
|
||||||
|
|
||||||
protected override void OnAfterRender(bool firstRender)
|
protected override void OnAfterRender(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
@@ -49,10 +61,18 @@
|
|||||||
private async Task ValidSubmit(EditContext context)
|
private async Task ValidSubmit(EditContext context)
|
||||||
{
|
{
|
||||||
ErrorMessages.Clear();
|
ErrorMessages.Clear();
|
||||||
|
Working = true;
|
||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
await OnValidSubmit.InvokeAsync(context);
|
await Task.Run(async () =>
|
||||||
await OnSubmit.InvokeAsync(context);
|
{
|
||||||
|
await InvokeAsync(() => OnValidSubmit.InvokeAsync(context));
|
||||||
|
await InvokeAsync(() => OnSubmit.InvokeAsync(context));
|
||||||
|
|
||||||
|
Working = false;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task InvalidSubmit(EditContext context)
|
private async Task InvalidSubmit(EditContext context)
|
||||||
@@ -66,7 +86,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
await OnInvalidSubmit.InvokeAsync(context);
|
await OnInvalidSubmit.InvokeAsync(context);
|
||||||
await OnSubmit.InvokeAsync(context);
|
await OnSubmit.InvokeAsync(context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,9 @@
|
|||||||
@if (User != null)
|
@if (User != null)
|
||||||
{
|
{
|
||||||
<div class="app-navbar-item ms-1 ms-lg-3">
|
<div class="app-navbar-item ms-1 ms-lg-3">
|
||||||
<div class="btn btn-icon btn-custom btn-icon-muted btn-active-light btn-active-color-primary w-35px h-35px w-md-40px h-md-40px position-relative" id="support_ticket_toggle">
|
<a href="/support" class="btn btn-icon btn-custom btn-icon-muted btn-active-light btn-active-color-primary w-35px h-35px w-md-40px h-md-40px position-relative">
|
||||||
<span class="svg-icon svg-icon-1">
|
<i class="bx bx-support"></i>
|
||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
</a>
|
||||||
<path opacity="0.3" d="M20 3H4C2.89543 3 2 3.89543 2 5V16C2 17.1046 2.89543 18 4 18H4.5C5.05228 18 5.5 18.4477 5.5 19V21.5052C5.5 22.1441 6.21212 22.5253 6.74376 22.1708L11.4885 19.0077C12.4741 18.3506 13.6321 18 14.8167 18H20C21.1046 18 22 17.1046 22 16V5C22 3.89543 21.1046 3 20 3Z" fill="currentColor"></path>
|
|
||||||
<rect x="6" y="12" width="7" height="2" rx="1" fill="currentColor"></rect>
|
|
||||||
<rect x="6" y="7" width="12" height="2" rx="1" fill="currentColor"></rect>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="app-navbar-item ms-1 ms-lg-3" id="kt_header_user_menu_toggle">
|
<div class="app-navbar-item ms-1 ms-lg-3" id="kt_header_user_menu_toggle">
|
||||||
|
|||||||
@@ -394,6 +394,11 @@ Discord id;Discord id
|
|||||||
Discord username;Discord username
|
Discord username;Discord username
|
||||||
Discord discriminator;Discord discriminator
|
Discord discriminator;Discord discriminator
|
||||||
The Name field is required.;The Name field is required.
|
The Name field is required.;The Name field is required.
|
||||||
|
An error occured while logging you in;An error occured while logging you in
|
||||||
|
You need to enter an email address;You need to enter an email address
|
||||||
|
You need to enter a password;You need to enter a password
|
||||||
|
You need to enter a password with minimum 8 characters in lenght;You need to enter a password with minimum 8 characters in lenght
|
||||||
|
Proccessing;Proccessing
|
||||||
The FirstName field is required.;The FirstName field is required.
|
The FirstName field is required.;The FirstName field is required.
|
||||||
The LastName field is required.;The LastName field is required.
|
The LastName field is required.;The LastName field is required.
|
||||||
The Address field is required.;The Address field is required.
|
The Address field is required.;The Address field is required.
|
||||||
@@ -401,4 +406,4 @@ The City field is required.;The City field is required.
|
|||||||
The State field is required.;The State field is required.
|
The State field is required.;The State field is required.
|
||||||
The Country field is required.;The Country field is required.
|
The Country field is required.;The Country field is required.
|
||||||
Street and house number requered;Street and house number requered
|
Street and house number requered;Street and house number requered
|
||||||
Max lenght reached;Max lenght reached
|
Max lenght reached;Max lenght reached
|
||||||
Reference in New Issue
Block a user