reload grant value to db when add/delete provider

This commit is contained in:
Zhuang 2018-04-21 12:29:00 +08:00
parent 6b8f430872
commit e69dcc433b

View File

@ -34,8 +34,7 @@ module.exports = async cb => {
name: 'users-permissions' name: 'users-permissions'
}); });
if (!await pluginStore.get({key: 'grant'})) { const grantValue = {
const value = {
email: { email: {
enabled: true, enabled: true,
icon: 'envelope' icon: 'envelope'
@ -75,8 +74,12 @@ module.exports = async cb => {
callback: '/auth/twitter/callback' callback: '/auth/twitter/callback'
} }
}; };
const prevGrantValue = await pluginStore.get({key: 'grant'})
await pluginStore.set({key: 'grant', value}); // store grant auth config to db
// when plugin_users-permissions_grant is not existed in db
// or we have added/deleted provider here.
if (!prevGrantValue || !_.isEqual(_.keys(prevGrantValue), _.keys(grantValue))) {
await pluginStore.set({key: 'grant', value: grantValue});
} }
if (!await pluginStore.get({key: 'email'})) { if (!await pluginStore.get({key: 'email'})) {