mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
fix: OAuth flow by setting scope and cookie to 'lax'
This commit is contained in:
1 parent
df140c64f8
commit
455fde41ab
5 files changed
+12
-5
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { User } from '@linux-odyssey/models'
|
||||
import type { Profile } from 'passport'
|
||||
import type { VerifyCallback } from 'passport-oauth2'
|
||||
import logger from '../utils/logger.js'
|
||||
|
||||
export default async function oauthVerify(
|
||||
provider: string,
|
||||
@@ -37,6 +38,7 @@ export default async function oauthVerify(
|
||||
email: user.email,
|
||||
})
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
return cb(
|
||||
err instanceof Error ? err : new Error('An unknown error occurred')
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import passport from 'passport'
|
||||
import { UserProfile } from '@linux-odyssey/models'
|
||||
import type { Express } from 'express'
|
||||
import { UserProfile } from '@linux-odyssey/models'
|
||||
import passwordStrategy from './passwordStrategy.js'
|
||||
import jwtStrategy from './jwtStrategy.js'
|
||||
import googleStrategy from './googleStrategy.js'
|
||||
@@ -30,7 +30,8 @@ passport.serializeUser((user: Express.User, done) => {
|
||||
process.nextTick(async () => {
|
||||
try {
|
||||
if (!('id' in user)) {
|
||||
done(new Error('User has no _id'))
|
||||
// OAuth new user
|
||||
done(null, user)
|
||||
return
|
||||
}
|
||||
const { id } = user
|
||||
@@ -39,6 +40,7 @@ passport.serializeUser((user: Express.User, done) => {
|
||||
}
|
||||
done(null, user)
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
done(err)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user