feat: add error handling for oauthVerify

This commit is contained in:
wancat committed 2023-11-18 21:46:03 +08:00
1 parent 8d0ec00536
commit 8430ce4428
1 file changed
+4
+4
View File
@@ -2,6 +2,7 @@ import { User } from '@linux-odyssey/models'
export default async function oauthVerify(provider, profile, query, cb) { export default async function oauthVerify(provider, profile, query, cb) {
process.nextTick(async () => { process.nextTick(async () => {
try {
const email = profile.emails[0]?.value const email = profile.emails[0]?.value
if (!email) { if (!email) {
return cb(new Error('No email found')) return cb(new Error('No email found'))
@@ -24,5 +25,8 @@ export default async function oauthVerify(provider, profile, query, cb) {
} }
return cb(null, user) return cb(null, user)
} catch (err) {
return cb(err)
}
}) })
} }