-
-
Notifications
You must be signed in to change notification settings - Fork 155
The login component is an authentication form for users of an application #1058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5d5d1f9
The login component is an authentication form for users of an applica…
b356cc8
username_icon and password_icon attributes
cb8fa2d
Fixing a regression with the class attribute.
2570bda
Documentation improved
ce4ffd3
Documentation improved
c28cf2a
Merge branch 'main' into login
lovasoa 722dc74
add an error_message property to the login component
lovasoa cfea904
The login component is an authentication form for users of an applica…
eb1f43c
username_icon and password_icon attributes
36ab34f
Fixing a regression with the class attribute.
5aa6acb
Documentation improved
3d7f780
Documentation improved
cc95ae2
Improve login component documentation and usability
lovasoa 5a6192f
Merge olivierauverlot/login: combine local defaults with error_messag…
lovasoa d542a8a
update changelog
lovasoa 5ee781c
use the login component in the user auth example
lovasoa abe136d
fix labels semantics in login component
lovasoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| INSERT INTO component(name, icon, description, introduced_in_version) VALUES | ||
| ('login', 'password-user', ' | ||
| The login component is an authentication form with numerous customization options. | ||
| It offers the main functionalities for this type of form. | ||
| The user can enter their username and password. | ||
| There are many optional attributes such as the use of icons on input fields, the insertion of a link to a page to reset the password, an option for the application to maintain the user''s identity via a cookie. | ||
| It is also possible to set the title of the form, display the company logo, or customize the appearance of the form submission button. | ||
|
|
||
| This component should be used in conjunction with other components such as [authentication](component.sql?component=authentication) and [cookie](component.sql?component=cookie). | ||
| It does not implement any logic and simply collects the username and password to pass them to the code responsible for authentication. | ||
|
|
||
| A few things to know : | ||
| - The form uses the POST method to transmit information to the destination page, | ||
| - The user''s username and password are entered into fields with the names `username` and `password`, | ||
| - To obtain the values of username and password, you must use the variables `:username` and `:password`, | ||
| - To know if the user wants their identity to be remembered, you must read the value of the variable `:remember`. | ||
| ', '0.39.0'); | ||
|
|
||
| INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'login', * FROM (VALUES | ||
| ('title','Title of the authentication form.','TEXT',TRUE,TRUE), | ||
| ('enctype','Form data encoding.','TEXT',TRUE,TRUE), | ||
| ('action','An optional link to a target page that will handle the results of the form. ','TEXT',TRUE,TRUE), | ||
| ('error_message','An error message to display above the form, typically shown after a failed login attempt.','TEXT',TRUE,TRUE), | ||
| ('username','Label and placeholder for the user account identifier text field.','TEXT',TRUE,FALSE), | ||
| ('password','Label and placeholder for the password field.','TEXT',TRUE,FALSE), | ||
| ('username_icon','Icon to display on the left side of the input field, on the same line.','ICON',TRUE,TRUE), | ||
| ('password_icon','Icon to display on the left side of the input field, on the same line.','ICON',TRUE,TRUE), | ||
| ('image','The URL of an centered image displayed before the title.','URL',TRUE,TRUE), | ||
| ('forgot_password_text','A text for the link allowing the user to reset their password. If the text is empty, the link is not displayed.','TEXT',TRUE,TRUE), | ||
| ('forgot_password_link','The link to the page allowing the user to reset their password.','TEXT',TRUE,TRUE), | ||
| ('remember_me_text','A text for the option allowing the user to request the preservation of their identity. If the text is empty, the option is not displayed.','TEXT',TRUE,TRUE), | ||
| ('footer','A text placed at the bottom of the authentication form.','TEXT',TRUE,TRUE), | ||
| ('footer_md','A markdown text placed at the bottom of the authentication form. Useful for creating links to other pages (creating a new account, contacting technical support, etc.).','TEXT',TRUE,TRUE), | ||
| ('validate','The text to display in the button at the bottom of the form that submits the values.','TEXT',TRUE,TRUE), | ||
| ('validate_color','The color of the button at the bottom of the form that submits the values. Omit this property to use the default color.','COLOR',TRUE,TRUE), | ||
| ('validate_shape','The shape of the validation button.','TEXT',TRUE,TRUE), | ||
| ('validate_outline','A color to outline the validation button.','COLOR',TRUE,TRUE), | ||
| ('validate_size','The size of the validation button.','TEXT',TRUE,TRUE) | ||
| ) x; | ||
|
|
||
| -- Insert example(s) for the component | ||
| INSERT INTO example(component, description, properties) | ||
| VALUES ( | ||
| 'login', | ||
| 'Using the main options of the login component', | ||
| JSON( | ||
| '[ | ||
| { | ||
| "component": "login", | ||
| "action": "login.sql", | ||
| "image": "../assets/icon.webp", | ||
| "title": "Please login to your account", | ||
| "username": "Username", | ||
| "password": "Password", | ||
| "username_icon": "user", | ||
| "password_icon": "lock", | ||
| "forgot_password_text": "Forgot your password?", | ||
| "forgot_password_link": "reset_password.sql", | ||
| "remember_me_text": "Remember me", | ||
| "footer_md": "Don''t have an account? [Register here](register.sql)", | ||
| "validate": "Sign in" | ||
| } | ||
| ]' | ||
| ) | ||
| ), | ||
| ('login', 'Most basic login form', JSON('[{"component": "login"}]')); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,9 @@ | ||
| SELECT 'form' AS component, | ||
| SELECT 'login' AS component, | ||
| 'login.sql' AS action, | ||
| 'Sign in' AS title, | ||
| 'Sign in' AS validate, | ||
| 'login.sql' AS action; | ||
|
|
||
| SELECT 'username' AS name; | ||
| SELECT 'password' AS name, 'password' AS type; | ||
|
|
||
| SELECT 'alert' as component, | ||
| 'Sorry' as title, | ||
| 'We could not authenticate you. Please log in or [create an account](signup.sql).' as description_md, | ||
| 'alert-circle' as icon, | ||
| 'red' as color | ||
| WHERE $error IS NOT NULL; | ||
| 'Username' AS username, | ||
| 'Password' AS password, | ||
| 'user' AS username_icon, | ||
| 'lock' AS password_icon, | ||
| case when $error is not null then 'We could not authenticate you. Please log in or [create an account](signup.sql).' end as error_message_md, | ||
| 'Sign in' AS validate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| <div class="container" {{class}}> | ||
| <div class="row d-flex justify-content-center"> | ||
| <div class="col-md-6"> | ||
| <form | ||
| {{#if id}}id="{{id}}"{{/if}} | ||
| class="mt-3 mb-1" | ||
| method="post" | ||
| {{#if enctype}}enctype="{{enctype}}"{{/if}} | ||
| {{#if action}} | ||
| action="{{action}}" | ||
| {{else}} | ||
| {{#if id}}action="#{{id}}"{{/if}} | ||
| {{/if}} | ||
| > | ||
| {{#if image}} | ||
| <div class="form-group d-flex justify-content-center align-items-center mb-2"> | ||
| <img src="{{image}}"/> | ||
| </div> | ||
| {{/if}} | ||
| {{#if title}} | ||
| <h1 class="text-center mb-3">{{title}}</h1> | ||
| {{/if}} | ||
| {{#if (or error_message error_message_md)}} | ||
| <div class="alert alert-danger mb-3" role="alert"> | ||
| <div class="alert-icon"> | ||
| {{icon_img 'alert-circle'}} | ||
| </div> | ||
| <div class="overflow-auto w-100 remove-bottom-margin"> | ||
| {{~error_message~}} | ||
| {{{~markdown error_message_md~}}} | ||
| </div> | ||
| </div> | ||
| {{/if}} | ||
| <label class="form-label" for="username">{{username}}</label> | ||
| <div class="input-icon mb-3"> | ||
| <span class="input-icon-addon">{{icon_img (default username_icon 'user-circle')}}</span> | ||
| <input type="text" name="username" id="username" value="" class="form-control" placeholder="{{username}}" required="required" autofocus autocomplete="username"/> | ||
| </div> | ||
| <label class="form-label" for="password">{{password}} | ||
| {{#if forgot_password_text}} | ||
| <span class="form-label-description"><a href="{{forgot_password_link}}">{{forgot_password_text}}</a></span> | ||
| {{/if}} | ||
| </label> | ||
| <div class="input-icon mb-3"> | ||
| <span class="input-icon-addon">{{~icon_img (default password_icon 'key')~}}</span> | ||
| <input type="password" name="password" id="password" value="" class="form-control" placeholder="{{password}}" required="required" autocomplete="current-password" /> | ||
| </div> | ||
| {{#if remember_me_text}} | ||
| <label class="form-check"> | ||
| <input class="form-check-input" id="remember" name="remember" type="checkbox" /> | ||
| <span class="form-check-label">{{remember_me_text}}</span> | ||
| </label> | ||
| {{/if}} | ||
| <div class="form-group d-flex justify-content-center align-items-center"> | ||
| <input | ||
| class="btn | ||
| btn-{{default validate_color "primary"}} | ||
| {{#if validate_shape}} btn-{{validate_shape}} {{/if}} | ||
| {{#if validate_outline}} btn-outline-{{validate_outline}} {{/if}} | ||
| {{#if validate_size}} btn-{{validate_size}} {{/if}}" | ||
| type="submit" | ||
| name="submit" | ||
| value="{{default validate 'Login'}}"/> | ||
| </div> | ||
| {{#if (or footer footer_md)}} | ||
| <hr> | ||
| <div class="text-center mb-0"> | ||
| <small class="form-hint mt-0"> | ||
| {{#if footer}} | ||
| {{footer}} | ||
| {{else}} | ||
| {{#if footer_md}} | ||
| {{{markdown footer_md}}} | ||
| {{/if}} | ||
| {{/if}} | ||
| </small> | ||
| </div> | ||
| {{/if}} | ||
| </form> | ||
| </div> | ||
| </div> | ||
| </div> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.