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

Hot to disable forgot password

Solved by Pedro M View solution

Started by Erik 2 years ago · 10 replies · 303 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.).

Suggested topics

Topic Participants Replies Views Activity
Support · by Anna, 22 hours ago
2 70 1 hour ago
Support · by gtx, 1 week ago
4 233 2 days ago
Support · by Paul Hodges, 2 weeks ago
13 283 5 days ago
Support · by Anna, 3 weeks ago
9 340 1 week ago
Support · by TomW, 2 weeks ago
4 192 2 weeks ago