feat: add UserProfile collection, create on login

* add progress
This commit is contained in:
wancat authored and Lin, Hung-Shin committed 2023-11-14 10:44:52 +08:00
1 parent e981bff3bb
commit 45f12acbd9
5 files changed
+75 -22

No files matched your search

+5 -1
View File
@@ -1,4 +1,5 @@
import passport from 'passport'
import { UserProfile } from '@linux-odyssey/models'
import passwordStrategy from './passwordStrategy.js'
import jwtStrategy from './jwtStrategy.js'
import googleStrategy from './googleStrategy.js'
@@ -24,7 +25,10 @@ if (enabledMethods.github) {
}
passport.serializeUser((user, done) => {
process.nextTick(() => {
process.nextTick(async () => {
if (!(await UserProfile.exists({ user: user._id }))) {
UserProfile.create({ user: user._id })
}
done(null, {
_id: user._id,
username: user.username,