mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-16 08:04:45 -04:00
refactor(app.js): Move passport serialize and deserialize to auth module
This commit is contained in:
parent
7ef17fd4e6
commit
d88502e331
2 changed files with 22 additions and 19 deletions
19
app.js
19
app.js
|
@ -154,25 +154,6 @@ app.use(flash())
|
|||
app.use(passport.initialize())
|
||||
app.use(passport.session())
|
||||
|
||||
// serialize and deserialize
|
||||
passport.serializeUser(function (user, done) {
|
||||
logger.info('serializeUser: ' + user.id)
|
||||
return done(null, user.id)
|
||||
})
|
||||
passport.deserializeUser(function (id, done) {
|
||||
models.User.findOne({
|
||||
where: {
|
||||
id: id
|
||||
}
|
||||
}).then(function (user) {
|
||||
logger.info('deserializeUser: ' + user.id)
|
||||
return done(null, user)
|
||||
}).catch(function (err) {
|
||||
logger.error(err)
|
||||
return done(err, null)
|
||||
})
|
||||
})
|
||||
|
||||
// check uri is valid before going further
|
||||
app.use(require('./lib/web/middleware/checkURiValid'))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue