Skip to content

Commit

Permalink
Merge pull request #45 from dragonfruitnetwork/fix-obsolete-symbols
Browse files Browse the repository at this point in the history
fix redirections not taking place
  • Loading branch information
aspriddell authored Nov 26, 2022
2 parents 3bfe8d2 + 8cbc4c9 commit 6881c2f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
10 changes: 8 additions & 2 deletions DragonFruit.Sakura/Administration/AdminLayout.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@inherits LayoutComponentBase
@using Microsoft.Extensions.Options
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@inherits LayoutComponentBase
@layout DefaultLayout

<SakuraJumbotron>
Expand Down Expand Up @@ -34,9 +36,13 @@
[Inject]
private NavigationManager Navigation { get; set; }

[Inject]
private IOptionsSnapshot<RemoteAuthenticationOptions<OidcProviderOptions>> OptionsContainer { get; set; }

private void RedirectToLoginPage()
{
Navigation.NavigateTo($"/auth/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}");
var path = OptionsContainer.Get(Options.DefaultName).AuthenticationPaths.LogInPath;
Navigation.NavigateToLogin(path);
}

}
13 changes: 10 additions & 3 deletions DragonFruit.Sakura/Administration/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
<MudContainer MaxWidth="MaxWidth.Large">
<MudStack>
<MudPaper Elevation="0" Class="p-4">
<MudStack Row="true" AlignItems="AlignItems.Center">
<MudText>Welcome Back</MudText>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
@if (string.IsNullOrEmpty(Name))
{
<MudText>Welcome Back</MudText>
}
else
{
<MudText>Welcome Back, @Name</MudText>
}
<MudSpacer/>
<MudButton EndIcon="@Icons.Rounded.KeyboardArrowRight" Color="Color.Primary" Href="/admin/keychain">Manage Keychain</MudButton>
<MudButton EndIcon="@Icons.Rounded.VpnKey" Color="Color.Primary" Href="/admin/keychain">Manage Keychain</MudButton>
</MudStack>
</MudPaper>

Expand Down
6 changes: 6 additions & 0 deletions DragonFruit.Sakura/Administration/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using DragonFruit.Sakura.Network;
using DragonFruit.Sakura.Network.Requests;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;

namespace DragonFruit.Sakura.Administration
{
Expand All @@ -15,6 +16,10 @@ public partial class Index
[Inject]
private ApiClient Client { get; set; }

[Inject]
private AuthenticationStateProvider AuthenticationStateProvider { get; set; }

private string Name { get; set; }
private IReadOnlyList<ApiAppInfo> Apps { get; set; }

private AppFeatures SelectedAppFeature
Expand All @@ -37,6 +42,7 @@ private AppFeatures SelectedAppFeature
protected override async Task OnInitializedAsync()
{
Apps = await Client.PerformAsync<IReadOnlyList<ApiAppInfo>>(new AdminApiAppsListingRequest()).ConfigureAwait(false);
Name = await AuthenticationStateProvider.GetAuthenticationStateAsync().ContinueWith(t => t.Result.User.Identity?.Name).ConfigureAwait(false);
}
}
}
1 change: 1 addition & 0 deletions DragonFruit.Sakura/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static async Task Main(string[] args)
o.ProviderOptions.RedirectUri = "https://dragonfruit.network/auth/login-callback";
#endif
o.ProviderOptions.PostLogoutRedirectUri = "/";
o.ProviderOptions.DefaultScopes.Add("delegate");
o.AuthenticationPaths.LogInPath = "/auth/login";
Expand Down

0 comments on commit 6881c2f

Please sign in to comment.