feat: social login providers with dynamic instances
This commit is contained in:
@@ -15,19 +15,20 @@ module.exports = {
|
||||
clientSecret: conf.clientSecret,
|
||||
authorizationURL: 'https://discord.com/api/oauth2/authorize?prompt=none',
|
||||
callbackURL: conf.callbackURL,
|
||||
scope: 'identify email guilds'
|
||||
}, async (accessToken, refreshToken, profile, cb) => {
|
||||
scope: 'identify email guilds',
|
||||
passReqToCallback: true
|
||||
}, async (req, accessToken, refreshToken, profile, cb) => {
|
||||
try {
|
||||
if (conf.guildId && !_.some(profile.guilds, { id: conf.guildId })) {
|
||||
if (conf.guildId && !_.some(profile.guilds, { id: conf.guildId })) {
|
||||
throw new WIKI.Error.AuthLoginFailed()
|
||||
}
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
providerKey: req.params.strategy,
|
||||
profile: {
|
||||
...profile,
|
||||
displayName: profile.username,
|
||||
picture: `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.png`
|
||||
},
|
||||
providerKey: 'discord'
|
||||
}
|
||||
})
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
|
Reference in New Issue
Block a user