You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
using System.Net.Http.Headers;
|
|
|
|
namespace Biskilog_Accounting.Client.Layouts
|
|
{
|
|
public partial class MainLayout
|
|
{
|
|
protected override Task OnInitializedAsync()
|
|
{
|
|
CheckPermission();
|
|
return base.OnInitializedAsync();
|
|
}
|
|
protected override void OnAfterRender(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
CheckPermission();
|
|
}
|
|
base.OnAfterRender(firstRender);
|
|
}
|
|
private async void CheckPermission()
|
|
{
|
|
//Checks if user token is set else redirect user to login page
|
|
if (!await m_tokenService.IsTokenSet())
|
|
{
|
|
m_navigationManager.NavigateTo("/login");
|
|
}
|
|
else
|
|
{
|
|
string token = await m_tokenService.GetToken();
|
|
var authHeader = new AuthenticationHeaderValue("Bearer", token.Substring(6).Trim());
|
|
m_http.DefaultRequestHeaders.Authorization = authHeader;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|