mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +01:00
Compare commits
No commits in common. "f89b9edbc9525abda338eb567ec4e363b87ee6d8" and "bc619c62cb20d863846aa160065e010311ad3d87" have entirely different histories.
f89b9edbc9
...
bc619c62cb
2
DotBased
2
DotBased
|
@ -1 +1 @@
|
|||
Subproject commit 17f69824eb3a854be545c3517c8ecd4bb63eab7b
|
||||
Subproject commit 0fed89e140c1500495e01f1f836416f107dcdbce
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,7 @@
|
|||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
<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>
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)"/>
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1"/>
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(EmptyLayout)">
|
||||
|
@ -19,5 +10,4 @@
|
|||
<p>Page not found!</p>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
</CascadingAuthenticationState>
|
||||
</Router>
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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.
Loading…
Reference in New Issue
Block a user