Compare commits
3 Commits
main
...
partial-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faf349e0db | ||
|
|
915022bc08 | ||
|
|
a1c7110a94 |
@@ -84,38 +84,31 @@ const userSchema = mongoose.Schema(
|
||||
},
|
||||
googleId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true,
|
||||
index: true,
|
||||
},
|
||||
facebookId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true,
|
||||
index: true,
|
||||
},
|
||||
openidId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true,
|
||||
index: true,
|
||||
},
|
||||
ldapId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true,
|
||||
index: true,
|
||||
},
|
||||
githubId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true,
|
||||
index: true,
|
||||
},
|
||||
discordId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true,
|
||||
index: true,
|
||||
},
|
||||
appleId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true,
|
||||
index: true,
|
||||
},
|
||||
plugins: {
|
||||
type: Array,
|
||||
|
||||
@@ -3,6 +3,11 @@ const { isEnabled } = require('~/server/utils');
|
||||
const { findUser } = require('~/models');
|
||||
const { logger } = require('~/config');
|
||||
|
||||
/**
|
||||
* Returns a function that handles the social login flow for a given provider.
|
||||
* @param {string} provider - The provider name (e.g. 'google', 'facebook').
|
||||
* @param {Function} getProfileDetails - A function to extract user details from the provider profile.
|
||||
*/
|
||||
const socialLogin =
|
||||
(provider, getProfileDetails) => async (accessToken, refreshToken, idToken, profile, cb) => {
|
||||
try {
|
||||
@@ -31,6 +36,8 @@ const socialLogin =
|
||||
});
|
||||
return cb(null, newUser);
|
||||
}
|
||||
|
||||
return cb(null, null);
|
||||
} catch (err) {
|
||||
logger.error(`[${provider}Login]`, err);
|
||||
return cb(err);
|
||||
|
||||
Reference in New Issue
Block a user