-
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
12 changed files
with
96 additions
and
21 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
2 changes: 0 additions & 2 deletions
2
sources/Clients.Admin/Components/Pages/Authentications/AuthenticationTest.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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
@using Microsoft.AspNetCore.Authorization | ||
|
||
@page "/AuthenticationTest" | ||
@attribute [Authorize] | ||
|
||
|
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,9 +1,13 @@ | ||
@page "/Login" | ||
@using MadWorldNL.Clients.Admin.Services.Authentications | ||
@using Microsoft.AspNetCore.Components.Authorization | ||
@using MadWorldNL.Clients.Admin.Application.Authentications | ||
|
||
<p>@Message</p> | ||
|
||
<h3>Login</h3> | ||
|
||
<RadzenButton Click="@TryLogin" Text="Try to Login" /> | ||
|
||
@code { | ||
[Inject] | ||
public IAuthenticationService AuthenticationService { get; set; } = null!; | ||
|
@@ -13,10 +17,16 @@ | |
|
||
[Inject] | ||
public NavigationManager NavigationManager { get; set; } = null!; | ||
public void TryLogin() | ||
|
||
private string Message { get; set; } = string.Empty; | ||
private void TryLogin() | ||
{ | ||
var result = AuthenticationService.Login("[email protected]", "password", "http://localhost:5000"); | ||
if (!result.IsSuccess) return; | ||
var result = AuthenticationService.Login("[email protected]", "Password1234", "http://localhost:5000"); | ||
if (!result.IsSuccess) | ||
{ | ||
Message = "Something went wrong"; | ||
return; | ||
} | ||
|
||
((JwtAuthenticationStateProvider)AuthenticationStateProvider).Authenticate(result.AccessToken); | ||
NavigationManager.NavigateTo("/AuthenticationTest"); | ||
|
9 changes: 9 additions & 0 deletions
9
sources/Clients.Admin/Components/Pages/Authentications/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 @@ | ||
@namespace MadWorldNL.Clients.Admin.Components.Pages.Authentications | ||
@inject NavigationManager Navigation | ||
|
||
@code { | ||
protected override void OnInitialized() | ||
{ | ||
Navigation.NavigateTo("/Login"); | ||
} | ||
} |
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,6 +1,25 @@ | ||
<Router AppAssembly="typeof(Program).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)"/> | ||
<FocusOnNavigate RouteData="routeData" Selector="h1"/> | ||
</Found> | ||
</Router> | ||
<CascadingAuthenticationState> | ||
<Router AppAssembly="@typeof(App).Assembly"> | ||
<Found Context="routeData"> | ||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)"> | ||
<NotAuthorized> | ||
@if (context.User.Identity?.IsAuthenticated != true) | ||
{ | ||
<RedirectToLogin /> | ||
} | ||
else | ||
{ | ||
<p role="alert">You are not authorized to access this resource.</p> | ||
} | ||
</NotAuthorized> | ||
</AuthorizeRouteView> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1"/> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(Layout.MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> | ||
</CascadingAuthenticationState> |
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,11 +1,16 @@ | ||
@using System.Net.Http | ||
@using System.Net.Http.Json | ||
@using Microsoft.AspNetCore.Authorization | ||
@using Microsoft.AspNetCore.Components.Authorization | ||
@using Microsoft.AspNetCore.Components.Forms | ||
@using Microsoft.AspNetCore.Components.Routing | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using static Microsoft.AspNetCore.Components.Web.RenderMode | ||
@using Microsoft.AspNetCore.Components.Web.Virtualization | ||
@using static Microsoft.AspNetCore.Components.Web.RenderMode | ||
@using Microsoft.JSInterop | ||
@using Radzen | ||
@using Radzen.Blazor | ||
|
||
@using MadWorldNL.Clients.Admin | ||
@using MadWorldNL.Clients.Admin.Components | ||
@using MadWorldNL.Clients.Admin.Components | ||
@using MadWorldNL.Clients.Admin.Components.Pages.Authentications |
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