Skip to content

Simplify the Stimulus Controller #714

Open
@Spomky

Description

@Spomky

Description

The Stimulus Controller continued growing.
It should be better to split it and simplify the number of options.
This change will permit the controller to be in line with the last security changes.

It could use targets for username/assertion or any other option such as user verification or authenticator selection.

Example

{% extends 'base.html.twig' %}
​
{% block body %}
    {% if error is defined %}
        <div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
    {% endif %}
​
    <form
        action="{{ path('app_login') }}"
        method="post"
        {{ stimulus_controller('@web-auth/login',
             {
                 useBrowserAutofill: true,
                 requestOptionsUrl: path('webauthn.controller.request.request.login'),
             }
        ) }}
    >
        <label for="username">Usenrame:</label>
        <input
                    type="text"
                    id="username"
                    name="_username"
                    value="{{ last_username }}"
                    placeholder="Type your username here"
                    autocomplete="username webauthn"
                    {{ stimulus_target('@web-auth/login', 'username') }}
        >
        <input
                   type="hidden"
                   id="assertion"
                   name="_assertion"
                   {{ stimulus_target('@web-auth/login', 'assertion') }}
        >
        <button
                     id="login"
                     name="login"
                     type="submit"
                    {{ stimulus_action('@web-auth/login', 'login') }}
        >login</button>
    </form>
{% endblock %}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions