Skip to content

Commit

Permalink
Merge pull request #83 from project-fika/fix/register_pw_validation
Browse files Browse the repository at this point in the history
Fixed register password validation
  • Loading branch information
seionmoya authored Oct 24, 2024
2 parents 5b50f16 + 2452c0f commit c467b57
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Fuyu.Launcher/Pages/Register.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
<MudPaper Class="pa-4" Elevation="4">
<MudForm @ref="_form" @bind-IsValid="@_success" @bind-Errors="@_errors">
<MudTextField @bind-Value="_username" Label="Username" Required="true" RequiredError="Required" />
<MudTextField @bind-Value="_password" Label="Password" Required="true" RequiredError="Required"
InputType="InputType.Password"
HelperText="Choose a strong password" />
<MudTextField T="string" Label="Repeat the Password" Required="true" InputType="InputType.Password" Validation="@(new Func<string, string>(PasswordMatch))" />
<MudTextField @bind-Value="_password" @bind-Value:after="Password_Changed" Label="Password" Required="true" RequiredError="Required"
InputType="InputType.Password"
HelperText="Choose a strong password" />
<MudTextField @ref="_repeatPwField" T="string" Label="Repeat the Password" Required="true"
InputType="InputType.Password"
Validation="@(new Func<string, string>(PasswordMatch))" />
<div class="d-flex align-center justify-center mt-6">
<MudButton Variant="Variant.Filled" Color="Color.Tertiary" Disabled="@(!_success)" OnClick="Register_Clicked">Register</MudButton>
</div>
Expand All @@ -43,11 +45,18 @@
private string _username = string.Empty;
private string _password = string.Empty;

private MudTextField<string> _repeatPwField;

private string PasswordMatch(string arg)
{
return _password != arg ? "Passwords don't match" : null;
}

public void Password_Changed()
{
_repeatPwField.Validate();
}

public void Register_Clicked()
{
_form.Validate();
Expand Down

0 comments on commit c467b57

Please sign in to comment.