added proper error handling for user creation

This commit is contained in:
Sheen Capadngan
2023-05-18 00:12:28 +08:00
parent fac8affe78
commit 4b2e91da74
+4
View File
@@ -77,6 +77,7 @@ const initializePassport = async () => {
profile: any, profile: any,
cb: any cb: any
) => { ) => {
try {
const email = profile.emails[0].value; const email = profile.emails[0].value;
let user = await User.findOne({ let user = await User.findOne({
authProvider: AuthProvider.GOOGLE, authProvider: AuthProvider.GOOGLE,
@@ -104,6 +105,9 @@ const initializePassport = async () => {
req.providerAuthToken = providerAuthToken; req.providerAuthToken = providerAuthToken;
cb(null, profile); cb(null, profile);
} catch (err) {
cb(err);
}
})); }));
} }