Login
Login is a component that contains a login form. You can use it for authenticating the user with a username and password. It is compatible with password managers, supports internationalization and works on all device sizes.
Basic Login Component/Form
The basic Login component consists of a title (Log in), two input fields (Username and Password), and two buttons (Log in and Forgot password).
You can customize the form’s title and labels using internationalization.
The basic Login component can be used to create login pages featuring rich content.
|
Note
|
Password managers
Login is incompatible with password managers if placed inside another component’s [1] shadow root.
This is not an issue when using Login’s modal overlay.
|
Modal Overlay
Login features its own modal overlay. Use it to create simple login pages (that are full screen on mobile devices) or to handle authentication without a dedicated login page. You can also use it to handle re-authentication when the user’s session has expired.
The overlay can be opened programmatically or through user interaction, for example, by using a login button.
Header
The overlay has a header and the login form. By default, the header contains placeholders for the application’s title and description. Both properties are configurable.
Source code
login-overlay-header-preview.ts
login-overlay-header-preview.ts
Source code
LoginOverlayHeader.java
Validation
Login shows an error message when authentication fails. The error message consists of a title and a message. It is displayed directly underneath the form’s title.
Source code
login-validation-preview.ts
login-validation-preview.ts
Source code
LoginValidation.java
The error message is customizable using internationalization. It should contain instructions on how to resolve the problem.
More information can also be provided to the user, for example, by linking to a page with helpful material or by displaying contact information.
Source code
login-additional-information-preview.ts
login-additional-information-preview.ts
Source code
LoginAdditionalInformation.java
Internationalization (i18n)
Login’s titles, descriptions, labels, and messages are all customizable using internationalization.
Source code
login-overlay-internationalization-preview.ts
login-overlay-internationalization-preview.ts
Source code
LoginOverlayInternationalization.java
Header
The header is only shown for modal login forms.
| Property | Default value |
|---|---|
Title | "App name" |
Description | "Application description" |
Form
Customize the form’s title, input field and button labels.
| Property | Default value |
|---|---|
Title | "Log in" |
Username | "Username" |
Password | "Password" |
Submit | "Log in" |
Forgot password | "Forgot password" |
Technical
Handling Events
Login Event
You can add a listener to login events and/or define an action for which a POST request is fired. From the event, you can prevent the POST request.
The login button is disabled when clicked to prevent multiple submissions.
To restore it, call component.setEnabled(true).
Forgot Password
You can add an event listener so you can provide instructions for password recovery for your users.
Cross-Site Request Forgery (CSRF) Tokens
If the page contains the following meta tags with a CSRF token, the token is automatically included in a form POST request:
Source code
HTML
<meta name="_csrf_parameter" content="_csrf">
<meta name="_csrf" content="71dac59f-34ee-4b31-b478-2891cbd0c55d">This token is submitted as _csrf=71dac59f-34ee-4b31-b478-2891cbd0c55d, that is, using the _csrf_parameter content as the variable name and the _csrf content as the value.
9CA8E14E-A01E-4C48-8D08-D4B1E6A3D287