Add login page
This commit is contained in:
71
Hcs.WebApp/Components/Pages/Account/Login.razor
Normal file
71
Hcs.WebApp/Components/Pages/Account/Login.razor
Normal file
@ -0,0 +1,71 @@
|
||||
@page "/account/login"
|
||||
|
||||
@inject NotificationService NotificationService
|
||||
|
||||
<PageTitle>Вход в систему</PageTitle>
|
||||
|
||||
<RadzenCard class="rz-mx-auto" Style="max-width: 420px">
|
||||
<RadzenTemplateForm TItem="InputModel" Data=@Input Method="post" Action="@($"identity/login?returnUrl={ReturnUrl}")">
|
||||
<RadzenStack Gap="1rem" class="rz-p-sm-12">
|
||||
<RadzenText TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">Вход</RadzenText>
|
||||
<RadzenFormField Text="Логин" Variant="Variant.Outlined">
|
||||
<ChildContent>
|
||||
<RadzenTextBox Name="UserName" @bind-Value=@Input.UserName AutoCompleteType="AutoCompleteType.Username" />
|
||||
</ChildContent>
|
||||
<Helper>
|
||||
<RadzenRequiredValidator Component="UserName" Text="Поле 'Логин' обязательно к заполнению" />
|
||||
<RadzenLengthValidator Component="UserName" Min="6" Text="Длина поля 'Логин' должна быть не меньше 6" />
|
||||
<RadzenLengthValidator Component="UserName" Max="30" Text="Длина поля 'Логин' должна быть не больше 30" />
|
||||
</Helper>
|
||||
</RadzenFormField>
|
||||
<RadzenFormField Text="Пароль" Variant="Variant.Outlined">
|
||||
<ChildContent>
|
||||
<RadzenPassword Name="Password" @bind-Value=@Input.Password AutoCompleteType="AutoCompleteType.NewPassword" />
|
||||
</ChildContent>
|
||||
<Helper>
|
||||
<RadzenRequiredValidator Component="Password" Text="Поле 'Пароль' обязательно к заполнению" />
|
||||
<RadzenLengthValidator Component="Password" Min="6" Text="Длина поля 'Пароль' должна быть не меньше 6" />
|
||||
<RadzenLengthValidator Component="Password" Max="100" Text="Длина поля 'Пароль' должна быть не больше 100" />
|
||||
</Helper>
|
||||
</RadzenFormField>
|
||||
<RadzenButton ButtonType="ButtonType.Submit" Text="Войти"></RadzenButton>
|
||||
</RadzenStack>
|
||||
</RadzenTemplateForm>
|
||||
</RadzenCard>
|
||||
|
||||
@code {
|
||||
sealed class InputModel
|
||||
{
|
||||
public string UserName { get; set; } = "";
|
||||
|
||||
public string Password { get; set; } = "";
|
||||
}
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
InputModel Input { get; set; } = new();
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
string? Status { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
string? ReturnUrl { get; set; }
|
||||
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
base.OnAfterRender(firstRender);
|
||||
|
||||
if (firstRender)
|
||||
{
|
||||
if (Status == "failed")
|
||||
{
|
||||
NotificationService.Notify(new NotificationMessage()
|
||||
{
|
||||
Severity = NotificationSeverity.Error,
|
||||
Summary = "Ошибка",
|
||||
Detail = "Неверный логин или пароль",
|
||||
Duration = -1d
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user