redirection after first connexion #3796

Closed
opened 2026-02-05 07:30:09 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @TomBachelot on GitHub (May 10, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

i would like to know if it is possible to set up a redirection to a bookstack specific page for a user when it's their first connexion ?

Exact BookStack Version

BookStack v23.05.1

Log Content

No response

PHP Version

PHP Version 8.2.4

Hosting Environment

Xampp control panel v3.3.0 on windows 10

Originally created by @TomBachelot on GitHub (May 10, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario i would like to know if it is possible to set up a redirection to a bookstack specific page for a user when it's their first connexion ? ### Exact BookStack Version BookStack v23.05.1 ### Log Content _No response_ ### PHP Version PHP Version 8.2.4 ### Hosting Environment Xampp control panel v3.3.0 on windows 10
OVERLORD added the 🐕 Support label 2026-02-05 07:30:09 +03:00
Author
Owner

@ssddanbrown commented on GitHub (May 10, 2023):

No way built-in to do this.

Could hack something in using the logical theme system though. If you're willing to attempt using this, and are ideally familiar with PHP, then I can provide some high-level guidance on approach if needed.

@ssddanbrown commented on GitHub (May 10, 2023): No way built-in to do this. Could hack something in using the [logical theme system](https://github.com/BookStackApp/BookStack/blob/development/dev/docs/logical-theme-system.md) though. If you're willing to attempt using this, and are ideally familiar with PHP, then I can provide some high-level guidance on approach if needed.
Author
Owner

@TomBachelot commented on GitHub (May 10, 2023):

Yes please, I'm already using the logical theme system, so I am ready to hear your guidance !

@TomBachelot commented on GitHub (May 10, 2023): Yes please, I'm already using the logical theme system, so I am ready to hear your guidance !
Author
Owner

@ssddanbrown commented on GitHub (May 10, 2023):

Alright, so assuming "first connection" means first login, my thoughts would be like this:

  1. Hook into the "web middleware after" event:

ed96aa820e/app/Theming/ThemeEvents.php (L113-L123)

  1. Check if they're logged in and they don't have a specific flag via user settings.
  • Can access user settings via setting()->getForCurrentUser('setting_key_here')
  • Can check logged-in status via auth()->check().
  1. If (2) is true: set a specific user settings flag and redirect them as required.
  • Can set user settings via setting()->putForCurrentUser('setting_key_here', 'value_here')
  • Can redirect via returning a redirect('path') call from the middleware event handler.

Could possibly be some funky edge cases from this, but that's where I'd start.

@ssddanbrown commented on GitHub (May 10, 2023): Alright, so assuming "first connection" means first login, my thoughts would be like this: 1. Hook into the "web middleware after" event: https://github.com/BookStackApp/BookStack/blob/ed96aa820e63a8f7a3c74efc2d6803ff2facec8b/app/Theming/ThemeEvents.php#L113-L123 2. Check if they're logged in and they don't have a specific flag via user settings. - Can access user settings via `setting()->getForCurrentUser('setting_key_here')` - Can check logged-in status via `auth()->check()`. 3. If (2) is true: set a specific user settings flag and redirect them as required. - Can set user settings via `setting()->putForCurrentUser('setting_key_here', 'value_here')` - Can redirect via returning a `redirect('path')` call from the middleware event handler. Could possibly be some funky edge cases from this, but that's where I'd start.
Author
Owner

@TomBachelot commented on GitHub (May 10, 2023):

thanks i'll try to do my best with this !

@TomBachelot commented on GitHub (May 10, 2023): thanks i'll try to do my best with this !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3796