mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-10 09:24:56 +02:00
Update:Auth to use new user model
- Express requests include userNew to start migrating API controllers to new user model
This commit is contained in:
parent
59370cae81
commit
202ceb02b5
14 changed files with 626 additions and 392 deletions
|
@ -89,9 +89,25 @@ class Server {
|
|||
this.io = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware to check if the current request is authenticated
|
||||
* req.user is set if authenticated to the OLD user object
|
||||
* req.userNew is set if authenticated to the NEW user object
|
||||
*
|
||||
* @param {import('express').Request} req
|
||||
* @param {import('express').Response} res
|
||||
* @param {import('express').NextFunction} next
|
||||
*/
|
||||
authMiddleware(req, res, next) {
|
||||
// ask passportjs if the current request is authenticated
|
||||
this.auth.isAuthenticated(req, res, next)
|
||||
this.auth.isAuthenticated(req, res, () => {
|
||||
if (req.user) {
|
||||
// TODO: req.userNew to become req.user
|
||||
req.userNew = req.user
|
||||
req.user = Database.userModel.getOldUser(req.user)
|
||||
}
|
||||
next()
|
||||
})
|
||||
}
|
||||
|
||||
cancelLibraryScan(libraryId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue