mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 23:24:03 +00:00
Can disable a provider
This commit is contained in:
parent
fc22f13cfc
commit
5e8259af73
@ -30,24 +30,31 @@ module.exports = cb => {
|
||||
if (!_.get(strapi.plugins['users-permissions'], 'config.grant')) {
|
||||
try {
|
||||
const grant = {
|
||||
local: {
|
||||
enabled: true
|
||||
},
|
||||
facebook: {
|
||||
enabled: false,
|
||||
key: '',
|
||||
secret: '',
|
||||
callback: '/auth/facebook/callback',
|
||||
scope: ['email']
|
||||
},
|
||||
google: {
|
||||
enabled: false,
|
||||
key: '',
|
||||
secret: '',
|
||||
callback: '/auth/google/callback',
|
||||
scope: ['email']
|
||||
},
|
||||
github: {
|
||||
enabled: false,
|
||||
key: '',
|
||||
secret: '',
|
||||
callback: '/auth/github/callback'
|
||||
},
|
||||
linkedin2: {
|
||||
enabled: false,
|
||||
key: '',
|
||||
secret: '',
|
||||
callback: '/auth/linkedin2/callback',
|
||||
|
||||
@ -25,6 +25,21 @@ module.exports = strapi => {
|
||||
|
||||
const grant = new Grant(strapi.plugins['users-permissions'].config.grant);
|
||||
|
||||
strapi.app.use(async (ctx, next) => {
|
||||
if (_.startsWith(ctx.request.url, '/connect') && ctx.request.method === 'GET') {
|
||||
const provider = _.last(ctx.request.url.split('/'));
|
||||
const config = strapi.plugins['users-permissions'].config.grant[provider];
|
||||
|
||||
if (_.get(config, 'enabled')) {
|
||||
await next();
|
||||
} else {
|
||||
return ctx.badRequest(null, 'This provider is disabled.');
|
||||
}
|
||||
} else {
|
||||
await next();
|
||||
}
|
||||
});
|
||||
|
||||
strapi.app.use(mount(grant));
|
||||
|
||||
cb();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user