-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@page "/account/register" | ||
@inherits RegisterBase | ||
|
||
<Title Main="Register" Sub="Create a new account" /> | ||
|
||
<div class="login"> | ||
|
||
<ValidationSummary ErrorMessages="@ErrorMessages" /> | ||
<div class="row"> | ||
<div class="col-md-4"> | ||
<section> | ||
<form onsubmit="@OnSubmitAsync"> | ||
<div class="form-group"> | ||
<label for="UserName">User name</label> | ||
<input id="UserName" class="form-control" type="text" autofocus bind="@UserName" /> | ||
</div> | ||
<div class="form-group"> | ||
<label for="Password">Password</label> | ||
<input id="Password" class="form-control" type="password" bind="@Password" /> | ||
</div> | ||
<div class="form-group"> | ||
<label for="ConfirmPassword">Confirm password</label> | ||
<input id="ConfirmPassword" class="form-control" type="password" bind="@ConfirmPassword" /> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Register</button> | ||
</form> | ||
</section> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.AspNetCore.Blazor.Components; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Money.Pages | ||
{ | ||
public class RegisterBase : BlazorComponent | ||
{ | ||
public string UserName { get; set; } | ||
public string Password { get; set; } | ||
public string ConfirmPassword { get; set; } | ||
|
||
public List<string> ErrorMessages { get; } = new List<string>(); | ||
|
||
protected Task OnSubmitAsync() | ||
{ | ||
if (Validate()) | ||
{ | ||
UserName = null; | ||
Password = null; | ||
ConfirmPassword = null; | ||
|
||
ErrorMessages.Add("Passed ;-)"); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
protected bool Validate() | ||
{ | ||
ErrorMessages.Clear(); | ||
|
||
if (String.IsNullOrEmpty(UserName)) | ||
ErrorMessages.Add("Please, fill user name."); | ||
|
||
if (String.IsNullOrEmpty(Password)) | ||
ErrorMessages.Add("Please, fill password."); | ||
|
||
if (String.IsNullOrEmpty(ConfirmPassword)) | ||
ErrorMessages.Add("Please, fill password confirmation."); | ||
else if (Password != ConfirmPassword) | ||
ErrorMessages.Add("Password must match password confirmation."); | ||
|
||
return ErrorMessages.Count == 0; | ||
} | ||
} | ||
} |