auth fixes

This commit is contained in:
Adam 2024-05-22 17:40:30 +02:00
parent c61e413ebb
commit 06a1fc4cfb
5 changed files with 19 additions and 6 deletions

View File

@ -115,7 +115,7 @@
else
{
_logger.Info("No token stored yet");
NavManager.NavigateTo("/");
//NavManager.NavigateTo("/");
}
ComponentUpdateService.CallRequestRefresh();
@ -133,6 +133,7 @@
var userBasicDetail = JsonConvert.DeserializeObject<UserBasicDetails>(userDetailsStr);
UserDataService.Logout(userBasicDetail.RefreshToken);
AuthStateProvider.GetAuthenticationStateAsync();
SecureStorageHandler.ClearAllSecureStorageAsync();
sessionService.User = null;
sessionService.IsAuthenticated = false;

View File

@ -1,7 +1,8 @@
@page "/chat"
@using Microsoft.AspNetCore.Authorization
@using TIAMWebApp.Shared.Application.Services
@inject SignalRService SignalRService
@attribute [Authorize]
<h3>Chat</h3>
<div class="container mt-5">
<div class="card">

View File

@ -16,6 +16,8 @@ using TIAMWebApp.Shared.Application.Utility;
using TIAMSharedUI.Pages.Components;
using TIAMWebApp.Shared.Application.Models.ClientSide;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Components.Authorization;
namespace TIAMSharedUI.Shared.Components
{
@ -41,6 +43,8 @@ namespace TIAMSharedUI.Shared.Components
[Inject]
private IUserDataService UserDataService { get; set; }
[Inject] AuthenticationStateProvider AuthStateProvider { get; set; }
private bool enableLogin = true;
private bool enableEvents = false;
private bool enableTransfer = true;
@ -88,7 +92,7 @@ namespace TIAMSharedUI.Shared.Components
var userBasicDetail = JsonConvert.DeserializeObject<UserBasicDetails>(userDetailsStr);
serverResult = await UserDataService.Logout(userBasicDetail.RefreshToken);
}
await AuthStateProvider.GetAuthenticationStateAsync();
await SecureStorageHandler.ClearAllSecureStorageAsync();
sessionService.User = null;
sessionService.IsAuthenticated = false;

View File

@ -17,7 +17,10 @@
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<p>Sorry dude, but you're not authorized!</p>
<div class="text-center m-5">
<h1>Restricted area</h1>
<h2 style="font-size:small">Sorry, you are not authorized to view this!</h2>
</div>
</NotAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
@ -25,7 +28,10 @@
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
<div class="text-center m-5">
<h1>Oops...</h1>
<h2 style="font-size:small">Sorry, we can't find the content you asked for!</h2>
</div>
</LayoutView>
</NotFound>
</Router>

View File

@ -16,6 +16,7 @@ using TIAMWebApp.Shared.Application.Models;
using TIAMWebApp.Shared.Application.Models.ClientSide.Messages;
using TIAMWebApp.Shared.Application.Services;
using TIAMWebApp.Server.Services;
using TIAMWebApp.Shared.Application.Models.ClientSide;
namespace TIAMWebApp.Server.Controllers
{
@ -350,7 +351,7 @@ namespace TIAMWebApp.Server.Controllers
<p>{createdTransfer.FullName}</p>
<p>{createdTransfer.PassengerCount}</p>
<p>Please confirm the transfer by clicking on the following link:</p>
<p><a href=""https://www.touriam.com/mytransfer?{createdTransfer.Id}"">Confirm Transfer</a></p>
<p><a href=""https://{Setting.BaseUrl}/mytransfers/{createdTransfer.Id}"">Confirm Transfer</a></p>
<p>If you did not request this transfer, please disregard this email.</p>
<p>Thank you,<br/>Tour I Am team</p>
</body>