Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Hot to disable forgot password

Solved by Pedro M View solution

Started by Erik 2 years ago · 10 replies · 156 views
2 years ago

In the Admin login form, I would like to completely disable Forgot password (removing the button). I only need to login.
Is there a way?
Thank you

2 years ago

I don't think there is a way currently. You could submit a feature request on GitHub for Admin plugin

2 years ago

I think you can do this by making a simple modification to your theme. Copy the partials/login.html.twig file from the email plugin to the partials folder of your theme.
In this file you have some lines referring to forgot your password. Delete them. In following code block is in which you will have to make your changes.

TWIG
<div class="{{ form_button_outer_classes ?: 'form-actions secondary-accent' }}">
                    {% if config.plugins.login.rememberme.enabled and form.login.rememberme ?? true %}
                        <div class="form-data rememberme" data-grav-default="null" data-grav-disabled="true" data-grav-field="checkbox">
                            <div class="form-input-wrapper">
                                <input type="checkbox" value="1" name="rememberme" id="#rememberme">
                                <label class="inline" for="#rememberme" title="{{ 'PLUGIN_LOGIN.REMEMBER_ME_HELP'|t }}">{{ 'PLUGIN_LOGIN.REMEMBER_ME'|t }}</label>
                            </div>
                        </div>
                    {% endif %}

                    {% set forgot_button = form.login.forgot_button ?? true %}
                    {% set forgot_route = grav.login.getRoute('forgot') %}
                    {% if forgot_button and forgot_route %}
                    <a class="{{ form_button_classes ?: 'button secondary' }}" href="{{ base_url_relative ~ forgot_route }}"><i class="fa fa-exclamation-circle"></i> {{ 'PLUGIN_LOGIN.BTN_FORGOT'|t }}</a>
                    {% endif %}

                    <button class="{{ form_button_classes ?: 'button primary' }}" type="submit"  name="task" value="login.login"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_LOGIN.BTN_LOGIN'|t }}</button>
                </div>

You will also have to disable the forgot route option in the plugin settings, for example pointing to the same route as the login or leaving blank (to prevent them from writing the default path in the browser)

2 years ago Solution

I just realized that you might be referring to the admin panel login. Is that correct?

The answer above is for the login form for registered users of your website, not for users who can access the admin panel.

In this case, the admin plugin has its own login.html.twig file, inside the plugin's Grav theme. But of course, if you modify that file and then there are updates, your changes will be deleted.
I need to see how to override that partial, because it has the same name as the login plugin's (login.html.twig)

👍 1
2 years ago

Thank you @pmoreno. I was wondering if there was an option (perhaps undocumented).

2 years ago

I see you marked a solution, but is it though? As @pmoreno mentioned, that template change will be overwritten on the next admin update and you will see the button again.

I'm not sure if adding a template in your theme would work here (needs to be tested), because the file structure is different there.

I think this is a feature to be implemented in the admin plugin itself. That's why I suggested creating a feature request on the repo

2 years ago

I marked @pmoreno reply as solution because, at the moment, it's the only workaround possible.
I agree with you about implementing such a feature. IMHO it could be useful. Perhaps, not to everyone, but at least to someone 😁 For example, in my scenario, I'm the only user and I didn't configure any mail service on my VPS (because usually I rely on external services like AWS SES, Mailgun, etc.).

2 years ago

I just uploaded a PR to the login plugin repository to add the option to enable or disable the Forgot button, but the login plugin is different, as I said, from the admin plugin's login form.
For the latter modification, there may also be some option that I will have to investigate.

👍 1
2 years ago

Hi @pmoreno, thanks for your time.
I just added a comment to the PR you already closed.
IMHO such an option (for the admin login) would be useful, especially for non-developers and less technically skilled users.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 64 17 hours ago
Support · by Anna, 3 days ago
2 68 20 hours ago
Support · by Justin Young, 21 hours ago
1 35 21 hours ago
Support · by Duc , 1 week ago
2 71 6 days ago
Support · by Colin Hume, 1 week ago
2 63 6 days ago