Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix redirect to login #565

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Server.UI/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@
z-index: 9999;
}
</style>
<HeadOutlet />
<HeadOutlet @rendermode="new InteractiveServerRenderMode(prerender: false)" />
</head>

<body>
<Routes @rendermode="@RenderMode.InteractiveServer" />
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
<script src="_framework/blazor.web.js"></script>
<script type="text/javascript" src="https://alcdn.msauth.net/browser/2.23.0/js/msal-browser.min.js"></script>
<script src="js/msal/authConfig.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/Server.UI/Components/Redirections/RedirectToHome.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
@code {
protected override void OnInitialized()
{
NavigationManager.NavigateTo($"/", forceLoad: true);
NavigationManager.NavigateTo($"/", forceLoad: false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
@code {
protected override void OnInitialized()
{
NavigationManager.NavigateTo($"/pages/authentication/login", forceLoad: true);
NavigationManager.NavigateTo($"/pages/authentication/login", forceLoad: false);
}
}
69 changes: 4 additions & 65 deletions src/Server.UI/Components/Routes.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

<Fluxor.Blazor.Web.StoreInitializer />

<LoadingScreen IsLoaded="@_isLoaded" LayoutService="LayoutService">
<div class="page-transition @_transitionClass">

<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
Expand All @@ -18,16 +17,7 @@
<text>@L["Please wait, we are authorizing you..."]</text>
</Authorizing>
<NotAuthorized>

@if (context.User.Identity?.IsAuthenticated ?? false)
{
<p>@L["You are not authorized to be here. For more information, contact your system administrator."]</p>
}
else
{
<Login />
}

<RedirectToLogin/>
</NotAuthorized>
</AuthorizeRouteView>
</Found>
Expand All @@ -43,59 +33,8 @@
</NotFound>
</Router>
</CascadingAuthenticationState>
</div>
</LoadingScreen>
@code
{
private string _transitionClass = string.Empty;
private bool _isLoaded = true;

protected override void OnInitialized()
{
_transitionClass = Settings.EnableLoadingScreen ? "loadScreen-initial-hidden" : string.Empty;
if (Settings.EnableLoadingTransitionScreen)
{
NavManager.LocationChanged += HandleLocationChanged;
}
}

public void Dispose()
{
if (Settings.EnableLoadingTransitionScreen)
{
NavManager.LocationChanged -= HandleLocationChanged;
}
GC.SuppressFinalize(this);
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
LayoutService.SetBaseTheme(Theme.ApplicationTheme());
await LayoutService.ApplyUserPreferences(true);
if (Settings.EnableLoadingScreen)
{
_transitionClass = "";
_isLoaded = false;
StateHasChanged();
await Task.Delay(Settings.LoadingScreenDuration >= 0 ? Settings.LoadingScreenDuration : 2000);
_isLoaded = true;
StateHasChanged();
}
}
}

private async void HandleLocationChanged(object? sender, LocationChangedEventArgs e)
@code
{
if (Settings.EnableLoadingTransitionScreen)
{
_transitionClass = "";
_isLoaded = false;
StateHasChanged();
await Task.Delay(Settings.LoadingTransitionScreenDuration >= 0 ? Settings.LoadingTransitionScreenDuration : 600);
_isLoaded = true;
StateHasChanged();
}
}

}
Loading