Class LoginModel
- Namespace
- Fdyay.IdentityServer.UI.Pages.Account
- Assembly
- Fdyay.IdentityServer.UI.dll
The sign-in page: a username and password form, and a button for each external provider the client accepts.
public class LoginModel : PageModel, IAsyncPageFilter, IPageFilter, IFilterMetadata
- Inheritance
-
LoginModel
- Implements
- Inherited Members
Constructors
LoginModel(IUserSignInService, IIdentityServerInteractionService, IAuthenticationSchemeProvider, IEventService, IOptions<IdentityServerOptions>, ILogger<LoginModel>)
public LoginModel(IUserSignInService signIn, IIdentityServerInteractionService interaction, IAuthenticationSchemeProvider schemes, IEventService events, IOptions<IdentityServerOptions> options, ILogger<LoginModel> logger)
Parameters
signInIUserSignInServiceinteractionIIdentityServerInteractionServiceschemesIAuthenticationSchemeProvidereventsIEventServiceoptionsIOptions<IdentityServerOptions>loggerILogger<LoginModel>
Remarks
Signs in through IUserSignInService rather than against the test users directly, since 0.112.0, so
the same page signs ASP.NET Core Identity's users in once AddAspNetIdentity is called.
Properties
ClientName
The display name of the application waiting behind the return URL; null when there is none.
public string? ClientName { get; set; }
Property Value
EnableLocalLogin
Whether the page offers the username and password form: false for a client that disallows it.
public bool EnableLocalLogin { get; }
Property Value
Error
The message shown when a sign-in is refused; null when there is none.
public string? Error { get; set; }
Property Value
ExternalProviders
The external providers offered as buttons: every scheme with a display name other than the cookies', narrowed to the
client's IdentityProviderRestrictions when it has any.
public IReadOnlyList<LoginModel.ExternalProvider> ExternalProviders { get; }
Property Value
Input
The posted form: the username, the password and the return URL.
[BindProperty]
public LoginModel.InputModel Input { get; set; }
Property Value
Methods
ExternalLoginUrl(string)
Where the "sign in with" link for scheme goes.
public string ExternalLoginUrl(string scheme)
Parameters
schemestring
Returns
Remarks
One definition, used by the page and by the redirect above. Built twice, the two would answer the same question differently the first time either changed — and the difference would show up as a home-realm redirect that lands somewhere the button does not.
OnGetAsync()
Renders the sign-in form for whichever protocol request is waiting.
public Task<IActionResult> OnGetAsync()
Returns
Remarks
The return URL is read out of the query string by the configured parameter name rather than
bound by a fixed one. LoginReturnUrlParameter decides what this
server puts on the redirect, so binding returnUrl meant that a host which renamed it — which the
options invite, and the documentation recommends — sent the value under a name this page did not read.
The user then signed in successfully and was sent nowhere. 0.19.0's defect, reachable again through
configuration; the two pages that already did this correctly are Device and Error.
OnPostAsync()
Signs the user in with the posted username and password and sends the browser to the return URL — or to the site root when it is not one this server recognises. A refusal re-renders the page with Error set, as does a post for a client that does not allow local sign-in.
public Task<IActionResult> OnPostAsync()
Returns
- Task<IActionResult>
A redirect once signed in, or the page.