Comments (2)
Good to hear you're liking BookStack!
But I've run into a lack of knowledge on how to login the user from that point on.
Here's an example:
<?php
use BookStack\Theming\ThemeEvents;
use BookStack\Facades\Theme;
use BookStack\Users\Models\User;
use Illuminate\Http\Request;
Theme::listen(ThemeEvents::WEB_MIDDLEWARE_BEFORE, function (Request $request) {
$userEmailParam = $request->query('as_user_email');
// Ignore if no email parameter or if already logged in
if (!$userEmailParam || auth()->check()) {
return;
}
// Log user in if user matching email is found
$user = User::query()->where('email', $userEmailParam)->first();
if ($user) {
// Silent direct login:
auth()->login($user);
// Login via app process which includes MFA, email confirmations, logging etc...
// See https://github.com/BookStackApp/BookStack/blob/f32cfb4292f7e3b723b5f99aab17d0f3989c93b7/app/Access/LoginService.php#L26-L54
// Uncomment two lines below, and comment auth line above, to activate:
//$loginService = app()->make(\BookStack\Access\LoginService::class);
//$loginService->login($user, 'custom_query_auth');
}
});
Note: The above is a significant insecure addition so please don't add to your instance unless you understand the risk and how that applies to your usage context of BookStack. Also, this customization uses BookStack internal code which could break upon future update.
There's a couple of options in there depending on what you need. Users will remain logged in from that point onward for the email user for the duration of their session. Let me know if you need any part/detail explained further.
from bookstack.
Thanks so much for the sample code and help! That points me in the right direction! and I can see how it'd be rather insecure (someone guessing the admin e-mail).
I'll work on adding a couple extra unknowns to make it a little trickier for this particular use case. :-)
Thanks again!
from bookstack.
Related Issues (20)
- After upgrading from 23.x to 24.x, headers are not showing properly HOT 2
- Rate limit on password resets HOT 9
- migrate to 24.05 fails with "Class "Barryvdh\DomPDF\ServiceProvider" not found" HOT 4
- Attachment upload validation error message appears are shown as JSON
- PLEASE DELETE BUG - I found the problem
- bug in documentation - /dev/docs /visual-theme-system.md & corresponding YouTube video HOT 1
- php artisan cache:clear Make sure you have the appropriate permissions HOT 9
- Users are not shown any templates HOT 7
- Not Found error on /login URL HOT 9
- After version 24.02, comments on pages cannot add image content
- Suddenly get a 500 errors HOT 4
- Request for Comment: Process & scope for security announcements & CVEs HOT 7
- Wrong notification preferences URL in email HOT 2
- OIDC login with Authelia fails with v24.05 HOT 6
- Have a non-blank screen while exports run.
- Webhooks "send" based on book or shelf HOT 1
- Template Append to page content not working HOT 3
- Update custom alignment handing to also clean table `align` attributes
- Scheduled page publishing HOT 4
- Tiered permissions - Managers can promote employees to managers, but not to admins. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bookstack.