-
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
7 changed files
with
111 additions
and
3 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 |
---|---|---|
@@ -1 +1,48 @@ | ||
@page "/account/login" | ||
@page "/account/login" | ||
@inherits LoginBase | ||
|
||
<div class="login"> | ||
<div class="alert alert-info"> | ||
You can sign in as <strong>demo</strong> user with <strong>demo</strong> password or register your own account. | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-4"> | ||
<section> | ||
@if (IsError) | ||
{ | ||
<Alert Title="Error" Message="User name and password don't match." Mode="AlertMode.Error" /> | ||
} | ||
|
||
<form onsubmit="@OnSubmitAsync"> | ||
<div asp-validation-summary="All" class="text-danger"></div> | ||
<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"> | ||
<div class="checkbox"> | ||
<label for="RememberMe"> | ||
<input id="RememberMe" type="checkbox" bind="@IsPermanent" /> | ||
Remember me? | ||
</label> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<button type="submit" class="btn btn-primary">Log in</button> | ||
<button type="submit" class="btn btn-default" onclick="@OnDemoSubmitAsync">Login with <strong>demo</strong> user</button> | ||
</div> | ||
<div class="form-group"> | ||
<p> | ||
<a href="@Navigator.UrlAccountRegister()">Register as a new user?</a> | ||
</p> | ||
</div> | ||
</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,43 @@ | ||
using Microsoft.AspNetCore.Blazor.Components; | ||
using Money.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Money.Pages | ||
{ | ||
public class LoginBase : BlazorComponent | ||
{ | ||
[Inject] | ||
internal Navigator Navigator { get; set; } | ||
|
||
[Inject] | ||
internal ApiClient ApiClient { get; set; } | ||
|
||
protected string UserName { get; set; } | ||
protected string Password { get; set; } | ||
protected bool IsPermanent { get; set; } | ||
|
||
protected bool IsError { get; set; } | ||
|
||
protected Task OnSubmitAsync() | ||
=> LoginAsync(UserName, Password, IsPermanent); | ||
|
||
protected Task OnDemoSubmitAsync() | ||
=> LoginAsync("demo", "demo", false); | ||
|
||
private async Task LoginAsync(string userName, string password, bool isPermanent) | ||
{ | ||
IsError = false; | ||
|
||
string token = await ApiClient.LoginAsync(userName, password, isPermanent); | ||
if (string.IsNullOrEmpty(token)) | ||
{ | ||
IsError = true; | ||
return; | ||
} | ||
} | ||
} | ||
} |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -470,4 +470,8 @@ h4 { | |
|
||
.user { | ||
margin: 20px 15px; | ||
} | ||
|
||
.login { | ||
margin-top: 20px; | ||
} |