Table of Contents

Class UserAuthenticationViewModel

Namespace
Dynamicweb.Users.Frontend.UserAuthentication
Assembly
Dynamicweb.Users.dll

View model for the UserAuthentication frontend module.

public sealed class UserAuthenticationViewModel : ViewModelBase
Inheritance
UserAuthenticationViewModel
Inherited Members
Extension Methods

Examples

Full Razor template example:

@inherits ViewModelTemplate<Dynamicweb.Users.Frontend.UserAuthentication.UserAuthenticationViewModel> @using Dynamicweb.Users.Frontend.UserAuthentication

<form method="post"> <input type="hidden" name="redirect" value="@Model.RedirectAfterLogin" />

<label for="username">Email</label> <input type="text" name="username" id="username" required />

<label for="password">Password</label> <input type="password" name="password" id="password" required />

<button type="submit">Sign in</button>

@if (Model.Result != UserAuthenticationResultType.None) { <div class="login-result">@Translate(Model.Result.ToString())&lt;/div&gt; }

@if (Model.ExternalLogins?.Any() == true) { <ul> @foreach (var p in Model.ExternalLogins) { <li><button type="submit" name="ExternalLoginProviderId" value="@p.Id">@p.Name&lt;/button&gt;&lt;/li&gt; } </ul> } </form>

Remarks

This model is provided to Razor templates in /Templates/Users/UserAuthentication/Login. It contains links to password and user creation pages, external login providers, the redirect target, and the result of the most recent authentication attempt.

Templates typically render a form bound to RedirectAfterLogin and use Result to display success/error messages.

Properties

Gets or sets the link to the page where a user can set or reset their password.

public string? CreatePasswordLink { get; set; }

Property Value

string

Gets or sets the link to the page where a new user account can be created.

public string? CreateUserLink { get; set; }

Property Value

string

ExternalLogins

Gets the collection of configured external login providers available to the user (e.g., Google, Azure AD, etc.).

public ICollection<ExternalLoginViewModel> ExternalLogins { get; }

Property Value

ICollection<ExternalLoginViewModel>

LoginType

Gets or sets the login type

public LoginType LoginType { get; set; }

Property Value

LoginType

MfaCodeExpiration

Gets or sets code's date of expiration

public DateTimeOffset? MfaCodeExpiration { get; set; }

Property Value

DateTimeOffset?

RedirectAfterLogin

Gets or sets the resolved URL to redirect to after successful login.
This is either the referrer or a specific page depending on module settings.

public string? RedirectAfterLogin { get; set; }

Property Value

string

Result

Gets or sets the result of the most recent authentication attempt.
Use this value in your template to render success or error messages.

public UserAuthenticationResultType Result { get; set; }

Property Value

UserAuthenticationResultType

See Also

To top