mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
BREAKING: change user social login schema
This commit is contained in:
1 parent
9e935b320a
commit
81581c4635
8 files changed
+59
-32
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import { matchedData } from 'express-validator'
|
||||
import { User } from '@linux-odyssey/models'
|
||||
import { genJWT } from '../../utils/auth.js'
|
||||
import { createUser } from '../../models/userManager.js'
|
||||
import { asyncHandler } from '../../middleware/error.js'
|
||||
@@ -50,7 +49,7 @@ export function checkSession(req, res) {
|
||||
})
|
||||
}
|
||||
|
||||
export function socialLogin(req, res) {
|
||||
export function socialLoginHandler(req, res) {
|
||||
const { newUser } = req.user
|
||||
if (newUser) {
|
||||
req.session.newUser = newUser
|
||||
@@ -71,10 +70,13 @@ export const registerFromSession = asyncHandler(async (req, res, next) => {
|
||||
return
|
||||
}
|
||||
|
||||
newUser.username = username
|
||||
const user = new User(newUser)
|
||||
const { email, socialLogin } = newUser
|
||||
|
||||
await user.save()
|
||||
if (!socialLogin) {
|
||||
throw new Error('Socail Login not found')
|
||||
}
|
||||
|
||||
const user = await createUser(username, email, { socialLogin })
|
||||
|
||||
req.login(user, (err) => {
|
||||
if (err) {
|
||||
|
||||
Reference in new issue
Block a user