Compare commits

..

No commits in common. "f89b9edbc9525abda338eb567ec4e363b87ee6d8" and "bc619c62cb20d863846aa160065e010311ad3d87" have entirely different histories.

8 changed files with 16 additions and 89 deletions

@ -1 +1 @@
Subproject commit 17f69824eb3a854be545c3517c8ecd4bb63eab7b
Subproject commit 0fed89e140c1500495e01f1f836416f107dcdbce

View File

@ -1,18 +0,0 @@
@page "/Auth/Login"
@using SharpRSS.Blazor.Extensions
@inject NavigationManager NavigationManager
@attribute [AllowAnonymous]
<PageTitle>Login | SharpRSS</PageTitle>
@code {
private string RedirectAfterLogin { get; set; } = string.Empty;
protected override Task OnInitializedAsync()
{
RedirectAfterLogin = NavigationManager.GetQueryParameters().TryGetValue("RedirectUrl", out var redirectUrl) ? redirectUrl.ToString() : string.Empty;
//TODO: Checking based auth or external (OIDC, etc.)
return base.OnInitializedAsync();
}
}

View File

@ -1,29 +0,0 @@
@inject NavigationManager NavigationManager
<PageTitle>Redirecting...</PageTitle>
<MudElement>
<MudOverlay DarkBackground="true" Visible="true">
<MudProgressCircular Size="Size.Large" Color="Color.Primary" Indeterminate="true"/>
</MudOverlay>
</MudElement>
@code {
[CascadingParameter]
private Task<AuthenticationState> AuthStateTask { get; set; } = null!;
[Parameter]
[EditorRequired]
public string RedirectUri { get; set; }
private bool _isAuthenticated;
protected override async Task OnInitializedAsync()
{
var authState = await AuthStateTask;
if (authState.User.Identity != null) _isAuthenticated = authState.User.Identity.IsAuthenticated;
NavigationManager.NavigateTo(RedirectUri);
await base.OnInitializedAsync();
}
}

View File

@ -1,23 +1,13 @@
<CascadingAuthenticationState>
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
@*<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)"/>
<FocusOnNavigate RouteData="routeData" Selector="h1"/>*@
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(EmptyLayout)">
<Authorizing>
<p>Determining session state, please wait...</p>
</Authorizing>
<NotAuthorized>
<Redirector RedirectUri="/auth/login"/>
</NotAuthorized>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(EmptyLayout)">
@*TODO: Manage not found*@
<PageTitle>Not found!</PageTitle>
<p>Page not found!</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)"/>
<FocusOnNavigate RouteData="routeData" Selector="h1"/>
</Found>
<NotFound>
<LayoutView Layout="@typeof(EmptyLayout)">
@*TODO: Manage not found*@
<PageTitle>Not found!</PageTitle>
<p>Page not found!</p>
</LayoutView>
</NotFound>
</Router>

View File

@ -1,14 +0,0 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Primitives;
namespace SharpRSS.Blazor.Extensions;
public static class NavigationManagerExtensions
{
public static Dictionary<string, StringValues> GetQueryParameters(this NavigationManager navigationManager)
{
var uri = navigationManager.ToAbsoluteUri(navigationManager.Uri);
return QueryHelpers.ParseQuery(uri.Query);
}
}

View File

@ -23,10 +23,8 @@ builder.Services.AddBasedServerAuth(options =>
options.LogoutPath = "/auth/logout";
options.SeedData = service =>
{
service.CreateUserAsync(new UserModel() { UserName = "Admin", Email = "admin@example.com", Enabled = true, PasswordHash = "password", Roles =
[new RoleModel { Name = "Admin", Description = "Administration role." }]
});
service.CreateUserAsync(new UserModel() { UserName = "User", Email = "user@example.com", Enabled = true, PasswordHash = "password"});
/*service.CreateUserAsync(new UserModel() { UserName = "Admin", Email = "admin@example.com", Enabled = true, PasswordHash = "password", Roles = new List<RoleModel>() { new RoleModel() { Name = "Admin", Description = "Administration role." }}});
service.CreateUserAsync(new UserModel() { UserName = "User", Email = "user@example.com", Enabled = true, PasswordHash = "password"});*/
};
options.SetDataRepositoryType<MemoryAuthDataRepository>();
options.SetSessionStateProviderType<LocalStorageSessionStateProvider>();

Binary file not shown.