]> BookStack Code Mirror - hacks/blob - content/username-login/index.md
Updated username login hack after testing
[hacks] / content / username-login / index.md
1 +++
2 title = "Username-based Login"
3 author = "@ssddanbrown"
4 date = 2022-11-25T20:00:00Z
5 updated = 2024-10-08T11:00:00Z
6 tested = "v24.05.4"
7 +++
8
9 This is a hack to BookStack, using the theme system, so that login presents itself as a username.
10 Upon login attempt, this will match to a user of `<username>@<configured-domain>` within the database.
11
12 #### Considerations
13
14 - This assumes all users in your BookStack instance shares the same email domain.
15 - This overrides a large part of the login form so be extra aware this will be overriding any default changes to BookStack upon updates.
16 - Login page errors may still reference email address, and username will not be auto prefilled after failed login submission.
17 - Other functionality within BookStack can still require or use email, so it's generally a good idea to ensure the resulting email addresses would be valid, or email is disabled at a system level in some manner.
18
19 #### Options
20
21 - Change the `$emailDomain` variable on line 8 of `functions.php` to be the common email domain used in your BookStack instance (This will be auto-appended to usernames on login).
22
23 #### Code
24
25 {{<hack file="functions.php" type="logical">}}
26
27 {{<hack file="auth/parts/login-form-standard.blade.php" type="visual">}}