mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
change to use session for auth
+ replace BearerAuth to cookieAuth in swagger + add swagger.yaml to nodemon watch list
This commit is contained in:
1 parent
a6d02f2616
commit
be5cd152a9
13 files changed
+216
-71
No files matched your search
@@ -1,13 +0,0 @@
|
||||
import { Strategy as JwtStrategy, ExtractJwt } from 'passport-jwt'
|
||||
import config from '../config.js'
|
||||
|
||||
const jwtOptions = {
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
secretOrKey: config.jwtSecret,
|
||||
}
|
||||
|
||||
function verifyJwt(jwtPayload, done) {
|
||||
return done(null, jwtPayload)
|
||||
}
|
||||
|
||||
export default new JwtStrategy(jwtOptions, verifyJwt)
|
||||
@@ -1,6 +1,20 @@
|
||||
import passport from 'passport'
|
||||
import PasswordStrategy from './passwordStrategy.js'
|
||||
import JwtStrategy from './jwtStrategy.js'
|
||||
|
||||
passport.use(PasswordStrategy)
|
||||
passport.use(JwtStrategy)
|
||||
|
||||
passport.serializeUser((user, done) => {
|
||||
process.nextTick(() => {
|
||||
done(null, {
|
||||
_id: user._id,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
passport.deserializeUser((user, done) => {
|
||||
process.nextTick(() => {
|
||||
done(null, user)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user