77 lines
1.7 KiB
Plaintext
77 lines
1.7 KiB
Plaintext
@using Koogle.Application.Interfaces
|
|
@using Koogle.Application.Services
|
|
@using Koogle.Web.Store.AuthState
|
|
@using Microsoft.AspNetCore.Authorization
|
|
@using Microsoft.AspNetCore.Components.Authorization
|
|
@using Dispatcher = Fluxor.Dispatcher
|
|
|
|
@inherits FluxorComponent
|
|
|
|
@inject IAuthorizationService AuthorizationService
|
|
@inject AuthenticationStateProvider AuthStateProvider
|
|
@inject IUserService UserService
|
|
@inject NavigationManager NavigationManager
|
|
@inject ICurrentClubContext CurrentClubContext
|
|
@inject IState<AuthState> AuthState
|
|
@inject IDispatcher Dispatcher
|
|
|
|
<h3>AuthTest-Component</h3>
|
|
|
|
|
|
@if (_canEdit)
|
|
{
|
|
<button class="btn btn-success">Eintrag anlegen</button>
|
|
}
|
|
else
|
|
{
|
|
<p>Keine Berechtigung zum Editieren</p>
|
|
}
|
|
|
|
|
|
@if (AuthState.Value is { CurrentUser: not null })
|
|
{
|
|
<MudPaper>
|
|
<MudText>User: @AuthState.Value.CurrentUser.DisplayName</MudText>
|
|
</MudPaper>
|
|
}
|
|
|
|
<AuthorizeView Roles="SuperAdmin">
|
|
<Authorized>
|
|
<button class="btn btn-primary">Club anlegen</button>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
|
|
<AuthorizeView>
|
|
aktueller Club: @CurrentClubContext.ClubName
|
|
|
|
<LogoutButton/>
|
|
</AuthorizeView>
|
|
|
|
@if(AuthState.Value != null)
|
|
{
|
|
<ul>
|
|
<li>ClubViewer: @AuthState.Value.IsClubViewer</li>
|
|
</ul>
|
|
}
|
|
<MudButton OnClick="Test">TEST</MudButton>
|
|
@code {
|
|
|
|
|
|
private bool _canEdit;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
var state = await AuthStateProvider.GetAuthenticationStateAsync();
|
|
var user = state.User;
|
|
|
|
var result = await AuthorizationService.AuthorizeAsync(user, CurrentClubContext.ClubId, "ClubEditor");
|
|
_canEdit = result.Succeeded;
|
|
}
|
|
|
|
private void Test(MouseEventArgs obj)
|
|
{
|
|
Dispatcher.Dispatch(new LogoutCompleteAction());
|
|
}
|
|
|
|
}
|