[frontend/components] Correctly tag username and password fields
This commit is contained in:
parent
a130934787
commit
b427340d94
2 changed files with 37 additions and 42 deletions
|
@ -10,40 +10,41 @@
|
|||
@inject SessionService SessionService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IStringLocalizer<Localization> Loc;
|
||||
@inject MetadataService Metadata;
|
||||
@inject MetadataService Metadata;
|
||||
@layout UnauthLayout
|
||||
<div class="body">
|
||||
<img class="logo" src="/_content/Iceshrimp.Assets.Branding/splash.png"/>
|
||||
<span>
|
||||
<h3>@Loc["Login to {0}", Name ?? "this Iceshrimp.NET Instance."]</h3></span>
|
||||
<div class="login-form">
|
||||
<input placeholder="@Loc["Username"]" required="required"
|
||||
@bind="@Username"/>
|
||||
<input type="password" placeholder="@Loc["Password"]" required="required"
|
||||
@bind="@Password"/>
|
||||
<input placeholder="@Loc["Username"]" autocomplete="username" name="username" required="required"
|
||||
@bind="@Username"/>
|
||||
<input type="password" placeholder="@Loc["Password"]" autocomplete="current-password" name="current-password" required="required"
|
||||
@bind="@Password"/>
|
||||
<button class="button" @onclick="Submit" disabled="@Loading">@Loc["Login"]</button>
|
||||
</div>
|
||||
|
||||
@if (Loading)
|
||||
{
|
||||
<span>Loading!</span>
|
||||
}
|
||||
@if (Failure)
|
||||
{
|
||||
<span>Authentication Failed</span>
|
||||
}
|
||||
|
||||
@if (Loading)
|
||||
{
|
||||
<span>Loading!</span>
|
||||
}
|
||||
@if (Failure)
|
||||
{
|
||||
<span>Authentication Failed</span>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromQuery(Name = "rd")]
|
||||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
|
||||
private string? Redirect { get; set; }
|
||||
|
||||
|
||||
private string? Password { get; set; }
|
||||
private string? Username { get; set; }
|
||||
private bool Loading { get; set; }
|
||||
private bool Failure { get; set; }
|
||||
private string? Name { get; set; }
|
||||
private string? Name { get; set; }
|
||||
|
||||
private async Task Submit()
|
||||
{
|
||||
|
@ -100,6 +101,6 @@
|
|||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var metadata = await Metadata.Instance.Value;
|
||||
Name = metadata.Name;
|
||||
Name = metadata.Name;
|
||||
}
|
||||
}
|
|
@ -6,10 +6,10 @@
|
|||
@using Microsoft.Extensions.Localization
|
||||
@layout UnauthLayout
|
||||
@inject IStringLocalizer<Register> Loc;
|
||||
@inject MetadataService Metadata;
|
||||
@inject ApiService Api;
|
||||
@inject SessionService SessionService;
|
||||
@inject NavigationManager Navigation;
|
||||
@inject MetadataService Metadata;
|
||||
@inject ApiService Api;
|
||||
@inject SessionService SessionService;
|
||||
@inject NavigationManager Navigation;
|
||||
@if (State is State.Loaded)
|
||||
{
|
||||
<div class="body">
|
||||
|
@ -19,9 +19,10 @@
|
|||
@if (RegistrationAvailability is not Registrations.Closed)
|
||||
{
|
||||
<div class="register-form">
|
||||
<input placeholder="@Loc["Username"]" required="required"
|
||||
<input placeholder="@Loc["Username"]" autocomplete="username" name="username" required="required"
|
||||
@bind="@Username"/>
|
||||
<input type="password" required="required" placeholder="@Loc["Password"]"
|
||||
<input type="password" autocomplete="new-password" name="new-password" required="required"
|
||||
placeholder="@Loc["Password"]"
|
||||
@bind="@Password"/>
|
||||
@if (RegistrationAvailability is Registrations.Invite)
|
||||
{
|
||||
|
@ -29,7 +30,7 @@
|
|||
}
|
||||
<button class="button" @onclick="Submit" disabled="@Loading">@Loc["Register"]</button>
|
||||
</div>
|
||||
@if (Result is RegistrationResult.Failure)
|
||||
@if (Error)
|
||||
{
|
||||
<div>@Loc[RegistrationError ?? string.Empty]</div>
|
||||
}
|
||||
|
@ -42,15 +43,15 @@
|
|||
}
|
||||
|
||||
@code {
|
||||
private string? Username { get; set; }
|
||||
private string? Password { get; set; }
|
||||
private string? Invite { get; set; }
|
||||
private bool Loading { get; set; }
|
||||
private RegistrationResult Result { get; set; }
|
||||
private Registrations RegistrationAvailability { get; set; }
|
||||
private State State { get; set; } = State.Loading;
|
||||
private string? RegistrationError { get; set; }
|
||||
private string? Name { get; set; }
|
||||
private string? Username { get; set; }
|
||||
private string? Password { get; set; }
|
||||
private string? Invite { get; set; }
|
||||
private bool Loading { get; set; }
|
||||
private bool Error { get; set; }
|
||||
private Registrations RegistrationAvailability { get; set; }
|
||||
private State State { get; set; } = State.Loading;
|
||||
private string? RegistrationError { get; set; }
|
||||
private string? Name { get; set; }
|
||||
|
||||
private async Task Submit()
|
||||
{
|
||||
|
@ -58,7 +59,7 @@
|
|||
StateHasChanged();
|
||||
if (Username is null || Password is null)
|
||||
{
|
||||
Result = RegistrationResult.Failure;
|
||||
Error = true;
|
||||
RegistrationError = "Please fill out all fields";
|
||||
Loading = false;
|
||||
return;
|
||||
|
@ -94,19 +95,12 @@
|
|||
catch (ApiException e)
|
||||
{
|
||||
RegistrationError = e.Response.Message;
|
||||
Result = RegistrationResult.Failure;
|
||||
Error = true;
|
||||
Loading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private enum RegistrationResult
|
||||
{
|
||||
Incomplete,
|
||||
Success,
|
||||
Failure
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var metadata = await Metadata.Instance.Value;
|
||||
|
|
Loading…
Add table
Reference in a new issue