mirror of https://github.com/abpframework/abp.git
5 changed files with 49 additions and 15 deletions
@ -0,0 +1,28 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.AspNetCore.Components.Web; |
||||
|
using Volo.Abp.AspNetCore.Components.WebAssembly; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor; |
||||
|
|
||||
|
public static class CultureAwareRedirectToLoginHelper |
||||
|
{ |
||||
|
public static async Task RedirectAsync( |
||||
|
NavigationManager navigation, |
||||
|
string loginUrl, |
||||
|
IRouteBasedCultureUrlHelper cultureUrlHelper, |
||||
|
IOptions<AbpAspNetCoreComponentsWebOptions> webOptions) |
||||
|
{ |
||||
|
var cultureLoginUrl = await cultureUrlHelper.PrependCulturePrefixAsync(loginUrl); |
||||
|
if (webOptions.Value.IsBlazorWebApp) |
||||
|
{ |
||||
|
navigation.NavigateTo(cultureLoginUrl, forceLoad: true); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
navigation.NavigateToLogin(cultureLoginUrl); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,25 +1,22 @@ |
|||||
@inject NavigationManager Navigation |
|
||||
@using Volo.Abp.DependencyInjection |
@using Volo.Abp.DependencyInjection |
||||
@using Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme.Themes.Basic |
@using Volo.Abp.AspNetCore.Components.Web.MudBlazorBasicTheme.Themes.Basic |
||||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication |
@using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor |
||||
@using Microsoft.Extensions.Options |
@using Microsoft.Extensions.Options |
||||
|
@using Volo.Abp.AspNetCore.Components.WebAssembly |
||||
@using Volo.Abp.AspNetCore.Components.Web |
@using Volo.Abp.AspNetCore.Components.Web |
||||
@inherits RedirectToLogin |
@inherits RedirectToLogin |
||||
@attribute [ExposeServices(typeof(RedirectToLogin))] |
@attribute [ExposeServices(typeof(RedirectToLogin))] |
||||
@attribute [Dependency(ReplaceServices = true)] |
@attribute [Dependency(ReplaceServices = true)] |
||||
@inject IOptions<AuthenticationOptions> AuthenticationOptions |
@inject NavigationManager Navigation |
||||
|
@inject IOptions<AuthenticationOptions> AuthOptions |
||||
|
@inject IRouteBasedCultureUrlHelper CultureUrlHelper |
||||
@inject IOptions<AbpAspNetCoreComponentsWebOptions> AbpAspNetCoreComponentsWebOptions |
@inject IOptions<AbpAspNetCoreComponentsWebOptions> AbpAspNetCoreComponentsWebOptions |
||||
|
|
||||
@code { |
@code { |
||||
protected override void OnInitialized() |
protected override void OnInitialized() { } |
||||
|
|
||||
|
protected override Task OnInitializedAsync() |
||||
{ |
{ |
||||
if (AbpAspNetCoreComponentsWebOptions.Value.IsBlazorWebApp) |
return CultureAwareRedirectToLoginHelper.RedirectAsync(Navigation, AuthOptions.Value.LoginUrl, CultureUrlHelper, AbpAspNetCoreComponentsWebOptions); |
||||
{ |
|
||||
Navigation.NavigateTo(AuthenticationOptions.Value.LoginUrl, forceLoad: true); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
Navigation.NavigateToLogin(AuthenticationOptions.Value.LoginUrl); |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue