-
Notifications
You must be signed in to change notification settings - Fork 0
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
19 changed files
with
187 additions
and
17 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
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
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
18 changes: 18 additions & 0 deletions
18
sources/Clients.Identity.Blazor.Shared/Authentications/AuthenticationManager.cs
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,18 @@ | ||
using MadWorldNL.Clients.Identity.Api.Contracts.Authentications; | ||
|
||
namespace MadWorldNL.Clients.Identity.Blazor.Shared.Authentications; | ||
|
||
public class AuthenticationManager : IAuthenticationManager | ||
{ | ||
private readonly IAuthenticationService _authenticationService; | ||
|
||
public AuthenticationManager(IAuthenticationService authenticationService) | ||
{ | ||
_authenticationService = authenticationService; | ||
} | ||
|
||
public async Task<LoginProxyResponse> LoginAsync(LoginProxyRequest request) | ||
{ | ||
return await _authenticationService.LoginAsync(request); | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
sources/Clients.Identity.Blazor.Shared/Authentications/IAuthenticationManager.cs
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,8 @@ | ||
using MadWorldNL.Clients.Identity.Api.Contracts.Authentications; | ||
|
||
namespace MadWorldNL.Clients.Identity.Blazor.Shared.Authentications; | ||
|
||
public interface IAuthenticationManager | ||
{ | ||
Task<LoginProxyResponse> LoginAsync(LoginProxyRequest request); | ||
} |
15 changes: 15 additions & 0 deletions
15
sources/Clients.Identity.Blazor.Shared/Authentications/MyAuthenticationStateProvider.cs
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,15 @@ | ||
using System.Security.Claims; | ||
using Microsoft.AspNetCore.Components.Authorization; | ||
|
||
namespace MadWorldNL.Clients.Identity.Blazor.Shared.Authentications; | ||
|
||
public class MyAuthenticationStateProvider : AuthenticationStateProvider | ||
{ | ||
public override Task<AuthenticationState> GetAuthenticationStateAsync() | ||
{ | ||
var state = new AuthenticationState(new ClaimsPrincipal()); | ||
|
||
NotifyAuthenticationStateChanged(Task.FromResult(state)); | ||
return Task.FromResult(state); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@page "/Login" | ||
|
||
<ErrorMessage Show="@_showError" Message="There was an error logging in. " /> | ||
|
||
@TempLoginMessage | ||
|
||
<AuthorizeView> | ||
<Authorized> | ||
<h1>You are logged in</h1> | ||
</Authorized> | ||
<NotAuthorized> | ||
<h1>Not logged in</h1> | ||
<RadzenRow Gap="2rem" Class="rz-p-0 rz-p-lg-4"> | ||
<RadzenRow AlignItems="AlignItems.Center"> | ||
<RadzenFormField Text="Email" Variant="Variant.Filled" Style="width: 100%;"> | ||
<RadzenTextBox @bind-Value="@_loginRequest.Email" Style="width: 100%;" /> | ||
</RadzenFormField> | ||
</RadzenRow> | ||
<RadzenRow AlignItems="AlignItems.Center"> | ||
<RadzenFormField Text="Password" Variant="Variant.Filled" Style="width: 100%;"> | ||
<RadzenPassword @bind-Value="@_loginRequest.Password" aria-label="enter password" /> | ||
</RadzenFormField> | ||
</RadzenRow> | ||
<RadzenRow AlignItems="AlignItems.Center"> | ||
<RadzenButton Shade="Shade.Lighter" Click=@LoginAsync Text="Login" ButtonStyle="ButtonStyle.Primary"/> | ||
</RadzenRow> | ||
</RadzenRow> | ||
</NotAuthorized> | ||
</AuthorizeView> |
31 changes: 31 additions & 0 deletions
31
sources/Clients.Identity.Blazor.Shared/Pages/Login.razor.cs
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,31 @@ | ||
using MadWorldNL.Clients.Identity.Api.Contracts.Authentications; | ||
using MadWorldNL.Clients.Identity.Blazor.Shared.Authentications; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace MadWorldNL.Clients.Identity.Blazor.Shared.Pages; | ||
|
||
public partial class Login | ||
{ | ||
[Inject] public IAuthenticationManager AuthenticationManager { get; set; } = null!; | ||
|
||
private LoginProxyRequest _loginRequest = new(); | ||
private bool _showError = false; | ||
|
||
private string TempLoginMessage = string.Empty; | ||
|
||
public async Task LoginAsync() | ||
{ | ||
var response = await AuthenticationManager.LoginAsync(_loginRequest); | ||
|
||
if (!response.IsSuccess) | ||
{ | ||
_showError = true; | ||
|
||
return; | ||
} | ||
|
||
_showError = false; | ||
|
||
TempLoginMessage = response.Expiration.ToString(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
sources/Clients.Identity.Blazor.Shared/Pages/RedirectToLogin.razor
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,9 @@ | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
@inject NavigationManager Navigation | ||
|
||
@code { | ||
protected override void OnInitialized() | ||
{ | ||
Navigation.NavigateToLogin("/Login"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
sources/Clients.Identity.Blazor.Shared/RadzenExtra/ErrorMessage.razor
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,14 @@ | ||
@if (Show) | ||
{ | ||
<RadzenAlert AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter"> | ||
@Message | ||
</RadzenAlert> | ||
} | ||
|
||
@code { | ||
[Parameter] | ||
public bool Show { get; set; } | ||
|
||
[Parameter] | ||
public string Message { get; set; } = string.Empty; | ||
} |
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,4 +1,7 @@ | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using Microsoft.AspNetCore.Components.Authorization | ||
@using Microsoft.AspNetCore.Components.Web | ||
|
||
@using MadWorldNL.Clients.Identity.Blazor.Shared.RadzenExtra | ||
|
||
@using Radzen | ||
@using Radzen.Blazor |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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