Skip to content

Commit 87c0316

Browse files
committed
get permission tokens on start
1 parent 8fdef8c commit 87c0316

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Desktop/Services/AuthService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public sealed class AuthService
1717
private readonly OpenShockApi _apiClient;
1818
private readonly ConfigManager _configManager;
1919
public SelfResponse? SelfResponse { get; private set; }
20+
public TokenResponse? TokenSelf { get; private set; }
2021

2122
// NotAuthed
2223
// FailedAuth
@@ -68,6 +69,11 @@ public async Task Authenticate()
6869
if (!selfResponse.IsT0) throw new Exception("Failed to get self response");
6970
SelfResponse = selfResponse.AsT0.Value;
7071

72+
var tokenSelf = await _apiClient.Client!.GetTokenSelf();
73+
if (!tokenSelf.IsT0) throw new Exception("Failed to get token self response");
74+
TokenSelf = tokenSelf.AsT0.Value;
75+
76+
7177
_authState.Value = AuthStateType.Authed;
7278
}
7379
catch (Exception)

Desktop/Ui/Pages/Dash/Tabs/AppSettingsTab.razor

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@inject ISnackbar Snackbar
1010
@inject RepositoryManager RepositoryManager
1111
@inject NavigationManager NavigationManager
12+
@inject AuthService AuthService
1213
@implements IAsyncDisposable
1314

1415
@page "/dash/settings"
@@ -28,6 +29,20 @@
2829
<MudChip Value="RuntimeInformation.RuntimeIdentifier"></MudChip>
2930
</span>
3031
</div>
32+
33+
34+
<div class="d-flex gap-5 align-center pt-2">
35+
<span class="d-flex align-center">
36+
<MudText>Permissions: </MudText>
37+
@if (AuthService.TokenSelf is not null)
38+
{
39+
@foreach (var permission in AuthService.TokenSelf.Permissions)
40+
{
41+
<MudChip Value="permission"></MudChip>
42+
}
43+
}
44+
</span>
45+
</div>
3146
</MudPaper>
3247

3348
<MudPaper Outlined="true" Class="rounded-lg mud-paper-padding-margin">

0 commit comments

Comments
 (0)