我需要知道如何个性化和/或更改此消息的语言,我想这与IdentityServer4有关。
有什么想法吗?
您要查找的是RemoteAuthenticatorView
。
你可以在官方文件中找到更多关于你答案的详细信息。
@page "/security/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action">
@*authentication/login*
<LoggingIn></LoggingIn>
@*authentication/login-callback*
<CompletingLoggingIn></CompletingLoggingIn>
@*authentication/login-failed*
<LogInFailed></LogInFailed>
@*authentication/logout*
<LogOut></LogOut>
@*authentication/logout-callback*
<CompletingLogOut></CompletingLogOut>
@*authentication/logout-failed*
<LogOutFailed></LogOutFailed>
@*authentication/logged-out*
<LogOutSucceeded></LogOutSucceeded>
@*authentication/profile*
<UserProfile></UserProfile>
@*authentication/register*
<Registering></Registering>
</RemoteAuthenticatorView>
@code{
[Parameter]
public string Action { get; set; }
}
有必要在身份验证中添加一些标签。剃刀组件:
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action">
<LogInFailed>
<div class="alert alert-danger" role="alert">@strLogInFailed</div>
</LogInFailed>
<LogOut>
<div class="alert alert-info" role="alert">@strLogOut</div>
</LogOut>
<LogOutSucceeded>
<div class="alert alert-success" role="alert">@strLogOutSucceeded</div>
</LogOutSucceeded>
<LoggingIn>
<div class="alert alert-info" role="alert">@strLoggingIn</div>
</LoggingIn>
<CompletingLoggingIn>
<div class="alert alert-success" role="alert">@strCompletingLoggingIn</div>
</CompletingLoggingIn>
</RemoteAuthenticatorView>
@code {
[Parameter] public string Action { get; set; }
string strLogInFailed = "Your login was not successful.";
string strLogOut = "Trying to close your session.";
string strLogOutSucceeded = "Your session has been closed successfully.";
string strLoggingIn = "Redirecting to the login screen.";
string strCompletingLoggingIn = "Your login was successful.";
}
我在自定义身份验证用户界面中找到了如何做到这一点,顺便说一句,它解释了上的很多内容
如何使用IdentityServer4 保护Blazor WebAssembly
阅读后,我还检查了RemoteAuthenticatorView类
即使做到了这一点,仍然坚持">正在授权";消息
要更改消息"正在授权">
需要添加
<Authorizing>
<h1>Authorization in progress</h1>
<p>Only visible while authorization is in progress.</p>
</Authorizing>
到文件App.razor
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData"
DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<h1>Sorry</h1>
<p>You're not authorized to reach this page.</p>
<p>You may need to log in as a different user.</p>
</NotAuthorized>
<Authorizing>
<h1>Authorization in progress</h1>
<p>Only visible while authorization is in progress.</p>
</Authorizing>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<h1>Sorry</h1>
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
您可以在官方文档中找到更多详细信息。
您可以使用<Authorizing>
标记来覆盖默认文本。
<AuthorizeView>
<Authorizing>
<p class="authorizing">Authorizing...</p>
</Authorizing>
<Authorized>
<p class="authorized">Welcome, @context.User.Identity.Name!</p>
</Authorized>
<NotAuthorized>
<p class="not-authorized">You're not authorized, @(context.User.Identity.Name ?? "anonymous")</p>
</NotAuthorized>
</AuthorizeView>
来源:
https://github.com/dotnet/aspnetcore/blob/1ed72f8f5f14dfc5a4ebc9d5d116d63792caa7fc/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor