Closes #6664 - Allow override login form from theme
Closes #6664 (closed)
Change
This change allows users to override the theme templates by creating these template files:
- ispconfig/web/themes/my-theme
- templates
- login
- index.htm
- otp.htm
- password_reset.htm
- login
- templates
This was not possible before, because the _fileSearch
method in tpl.inc.php
did not consider login pages to be a module. The change I made corrects this behaviour by hard-coding a check to see if the $_SERVER['PHP_SELF']
(currently executing script) starts with /login/. This catches all three login pages that have templates + any future ones.
Testing
-
The default theme continues to work without any problems -
Tested setting the theme to and from default from the Tools > User Settings menu -
Tested setting the theme in the interface/lib/config.inc.php
-
Default index.htm
works normally -
Default password_reset.htm
works normally -
Default otp.htm
should work normally, but I haven't been able to test this
-
-
A custom theme can override the templates -
Overriding index.htm
works -
Overriding password_reset.htm
works -
Unsure if otp.htm
works, it should, but haven't been able to test it -
If a template isn't overridden in a custom theme, it falls back correctly (tested on index
andpassword_reset
) -
Tested setting theme through User Settings, works fine -
Tested setting theme in interface/lib/config.inc.php
-
-
I've clicked through the modules and can't find any broken pages. Everything seems in order -
Impersonating a user works fine, even if they have another theme configured, it switches without any issues
Stability/risk
I don't expect this change to cause any issues for users, seeing how the _fileSearch
method falls back to it's original behaviour if the configured theme doesn't override it.
Though do take note of how I implemented the fix: I check if the executing file starts with /login/
. I did this intentionally, so it would match the existing pages, but also any future templates in the login directory. Looking at login/logout.php
and login/login_as.php
I see some hard-coded HTML that may be worth separating into a template in the future.
Code styling
My VSCode removes indentation on empty lines when I save. This has caused a few minor formatting changes in the changed file. I see this as positive, since now the file is now consistent in that empty lines are actually empty.