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,16 +1,23 @@
|
||||
import { User, UserProfile } from '@linux-odyssey/models'
|
||||
import { hashPassword } from '../utils/auth.js'
|
||||
|
||||
export async function createUser(username, email, password) {
|
||||
export async function createUser(username, email, { password, socialLogin }) {
|
||||
const user = new User({
|
||||
username,
|
||||
email,
|
||||
})
|
||||
user.hashedPassword = await hashPassword(password)
|
||||
if (password) {
|
||||
user.hashedPassword = await hashPassword(password)
|
||||
}
|
||||
if (socialLogin) {
|
||||
user.socialLogins.set(socialLogin.provider, socialLogin)
|
||||
}
|
||||
await user.save()
|
||||
|
||||
const userProfile = new UserProfile({
|
||||
user,
|
||||
})
|
||||
await userProfile.save()
|
||||
|
||||
return user
|
||||
}
|
||||
Reference in new issue
Block a user