Login custom theme v41 - forgot to add "login-box"

Hi

Luckily this is not a real scenario but it does sound like an issue. While I’ll be asking the software team for a solution, I’m wondering if anyone has ideas or already knows the solution.

What if someone chose to create their own custom login page and forgot to add the “login-box”?

Just in case, I actually got logged out, I had added the login-box in the HTML but used CSS to hide it :sweat_smile:

Could be a secret way for members to login without showing the login box? :stuck_out_tongue:

Anyhow, I have removed the “display:none;” so others don’t miss out the chance exploring the v41 on play.dhis2.org/demo

:hearts:

Hi again!

I think I found the solution … I will share it tonight if no one else posts first. :slight_smile:

Hi @Gassim: we strongly encourage anyone who wants to use a custom login template to test the template before committing it to avoid these types of problems.

When you are changing to use a custom template in the settings app, you should open the login page (Login app | DHIS2) and confirm that the login box appears. If it does not, you need to check that the HTML includes an element with id login-box, e.g. <div id='login-box'></div>

However, if for some reason, you do save your custom login HTML without a login-box, there is a safe mode login available at: DHIS 2 Demo - Sierra Leone.

In the coming months, we will be working to add preview functionality to the settings app, so that this process is clearer and a preview step will be built into the template upload.

You may also want to submit a feature request to have the login app validate that the login-box is included in the HTML, and if not redirect or display link to the safe mode option. We considered this for the first iteration of the app, but decided to put more responsibility on users to check their HTML templates. However, as mentioned, we are looking into how to improve this experience and prevent errors in the future.

1 Like

Hi @tzemp

Exactly what I had in mind but I didn’t think I could find it in the docs: “/dhis-web-commons/security/login.action” safe mode login :grin:

So the solution, in that case would be to use instanceURL/dhis-web-commons/security/login.action

I understand and appreciate the decision to make it the responsibility on the users in this case, and it’s good to know they have the safe mode option just in case.

I also thought of another solution, which is to reset the login template using the API:
You can reset the login page theme using the API by making a POST request to /api/41/systemSettings/loginPageLayout including the loginPageLayout DEFAULT or SIDEBAR value in the request body, where content type is set to “text/plain”. As an example, you can use curl like this:

curl "play.im.dhis2.org/stable-2-41-0/api/41/systemSettings/loginPageLayout" -d "DEFAULT" -H "Content-Type: text/plain" -u admin:district

I added a pull request to the docs: DOCS: Include API request to reset login page back to default by gassims · Pull Request #1388 · dhis2/dhis2-docs · GitHub

Maybe adding the safe mode option as well will be helpful too! :slight_smile:

2 Likes

Yes. Thanks, @Gassim. That’s also a great suggestion for people who are comfortable interacting with the api from the command line.

1 Like

This assistance has been incredibly valuable and has truly saved my day

1 Like

Hi @sele

Welcome back to the community! Great to see you again :grin: And thank you so much for sharing. <3

1 Like