mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: pick username
* put new registered social login user to session data * ask to choose username * simplify checkUsername functions
This commit is contained in:
1 parent
5591689816
commit
182fcf643f
12 files changed
+244
-69
No files matched your search
@@ -5,8 +5,6 @@ import User from '../models/user.js'
|
||||
|
||||
function verify(accessToken, refreshToken, profile, cb) {
|
||||
process.nextTick(async () => {
|
||||
console.log(accessToken, refreshToken, profile)
|
||||
// cb('todo')
|
||||
const email = profile.emails[0]?.value
|
||||
if (!email) {
|
||||
cb(new Error('No email found'))
|
||||
@@ -21,16 +19,18 @@ function verify(accessToken, refreshToken, profile, cb) {
|
||||
displayName: profile.displayName,
|
||||
}
|
||||
if (!user) {
|
||||
user = new User({
|
||||
const newUser = {
|
||||
email,
|
||||
github,
|
||||
})
|
||||
} else if (user.github?.id) {
|
||||
}
|
||||
cb(null, { newUser })
|
||||
return
|
||||
}
|
||||
if (user.github?.id) {
|
||||
cb(new Error('Email already used and binded to another account'))
|
||||
return
|
||||
} else {
|
||||
user.github = github
|
||||
}
|
||||
user.github = github
|
||||
await user.save()
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,18 @@ function verify(issuer, profile, cb) {
|
||||
displayName: profile.displayName,
|
||||
}
|
||||
if (!user) {
|
||||
user = new User({
|
||||
const newUser = new User({
|
||||
email,
|
||||
google,
|
||||
})
|
||||
} else if (user.google?.id) {
|
||||
cb(null, { newUser })
|
||||
return
|
||||
}
|
||||
if (user.google?.id) {
|
||||
cb(new Error('Email already used and binded to another account'))
|
||||
return
|
||||
} else {
|
||||
user.google = google
|
||||
}
|
||||
user.google = google
|
||||
await user.save()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user