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'
});
if (!await pluginStore.get({key: 'grant'})) {
const value = {
const grantValue = {
email: {
enabled: true,
icon: 'envelope'
@ -75,8 +74,12 @@ module.exports = async cb => {
callback: '/auth/twitter/callback'
}
};
await pluginStore.set({key: 'grant', value});
const prevGrantValue = await pluginStore.get({key: 'grant'})
// 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'})) {