diff --git a/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js b/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js index 621ca22374..e80e1864a8 100644 --- a/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js +++ b/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js @@ -10,12 +10,13 @@ const createSchemaHandler = require('./schema-handler'); module.exports = function createComponentBuilder() { return { - setRelation({ key, modelName, attribute }) { + setRelation({ key, modelName, plugin, attribute }) { this.contentTypes.get(attribute.target).setAttribute( attribute.targetAttribute, generateRelation({ key, attribute, + plugin, modelName, }) ); @@ -93,6 +94,7 @@ module.exports = function createComponentBuilder() { this.setRelation({ key, modelName: contentType.modelName, + plugin: contentType.plugin, attribute, }); } @@ -153,6 +155,7 @@ module.exports = function createComponentBuilder() { return this.setRelation({ key, modelName: contentType.modelName, + plugin: contentType.plugin, attribute: newAttributes[key], }); } @@ -172,6 +175,7 @@ module.exports = function createComponentBuilder() { return this.setRelation({ key, modelName: contentType.modelName, + plugin: contentType.plugin, attribute: newAttribute, }); } @@ -185,6 +189,7 @@ module.exports = function createComponentBuilder() { this.setRelation({ key, modelName: contentType.modelName, + plugin: contentType.plugin, attribute, }); } @@ -227,9 +232,10 @@ module.exports = function createComponentBuilder() { const createContentTypeUID = ({ name }) => `application::${nameToSlug(name)}.${nameToSlug(name)}`; -const generateRelation = ({ key, attribute, modelName }) => { +const generateRelation = ({ key, attribute, plugin, modelName }) => { const opts = { via: key, + plugin, columnName: attribute.targetColumnName || undefined, }; diff --git a/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js b/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js index 6f69c3fe89..0ed9242674 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js +++ b/packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js @@ -70,6 +70,8 @@ class PopUpForm extends React.Component { return `${strapi.backendURL}/connect/twitter/callback`; case 'instagram': return `${strapi.backendURL}/connect/instagram/callback`; + case 'vk': + return `${strapi.backendURL}/connect/vk/callback`; default: { const value = get(this.props.values, 'callback', ''); diff --git a/packages/strapi-plugin-users-permissions/admin/src/translations/en.json b/packages/strapi-plugin-users-permissions/admin/src/translations/en.json index 02430b7533..8b80cf3b9a 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/translations/en.json +++ b/packages/strapi-plugin-users-permissions/admin/src/translations/en.json @@ -85,6 +85,7 @@ "PopUpForm.Providers.github.providerConfig.redirectURL": "The redirect URL to add in your GitHub application configurations", "PopUpForm.Providers.google.providerConfig.redirectURL": "The redirect URL to add in your Google application configurations", "PopUpForm.Providers.instagram.providerConfig.redirectURL": "The redirect URL to add in your Instagram application configurations", + "PopUpForm.Providers.vk.providerConfig.redirectURL": "The redirect URL to add in your VK application configurations", "PopUpForm.Providers.key.label": "Client ID", "PopUpForm.Providers.key.placeholder": "TEXT", "PopUpForm.Providers.linkedin2.providerConfig.redirectURL": "The redirect URL to add in your Linkedin application configurations", diff --git a/packages/strapi-plugin-users-permissions/admin/src/translations/ru.json b/packages/strapi-plugin-users-permissions/admin/src/translations/ru.json index da20f905f7..3391cb2539 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/translations/ru.json +++ b/packages/strapi-plugin-users-permissions/admin/src/translations/ru.json @@ -84,6 +84,7 @@ "PopUpForm.Providers.github.providerConfig.redirectURL": "URL-адрес перенаправления, который необходимо добавить в настройки GitHub приложения", "PopUpForm.Providers.google.providerConfig.redirectURL": "URL-адрес перенаправления, который необходимо добавить в настройки Google приложения", "PopUpForm.Providers.instagram.providerConfig.redirectURL": "URL-адрес перенаправления, который необходимо добавить в настройки Instagram приложения", + "PopUpForm.Providers.vk.providerConfig.redirectURL": "URL-адрес перенаправления, который необходимо добавить в настройки VK приложения", "PopUpForm.Providers.key.label": "Client ID", "PopUpForm.Providers.key.placeholder": "TEXT", "PopUpForm.Providers.linkedin2.providerConfig.redirectURL": "URL-адрес перенаправления, который необходимо добавить в настройки Linkedin приложения", diff --git a/packages/strapi-plugin-users-permissions/config/functions/bootstrap.js b/packages/strapi-plugin-users-permissions/config/functions/bootstrap.js index f546b1aaf2..67028d1226 100644 --- a/packages/strapi-plugin-users-permissions/config/functions/bootstrap.js +++ b/packages/strapi-plugin-users-permissions/config/functions/bootstrap.js @@ -89,6 +89,14 @@ module.exports = async () => { secret: '', callback: '/auth/instagram/callback', }, + vk: { + enabled: false, + icon: 'vk', + key: '', + secret: '', + callback: '/auth/vk/callback', + scope: ['email'], + }, }; const prevGrantConfig = (await pluginStore.get({ key: 'grant' })) || {}; // store grant auth config to db diff --git a/packages/strapi-plugin-users-permissions/services/Providers.js b/packages/strapi-plugin-users-permissions/services/Providers.js index 0d0b821739..671e5e2d00 100644 --- a/packages/strapi-plugin-users-permissions/services/Providers.js +++ b/packages/strapi-plugin-users-permissions/services/Providers.js @@ -370,6 +370,25 @@ const getProfile = async (provider, query, callback) => { }); break; } + case 'vk': { + const vk = new Purest({ provider: 'vk' }); + + vk.query() + .get('users.get') + .auth(access_token) + .qs({ id: query.raw.user_id, v: '5.013' }) + .request((err, res, body) => { + if (err) { + callback(err); + } else { + callback(null, { + username: `${body.response[0].last_name} ${body.response[0].first_name}`, + email: query.raw.email, + }); + } + }); + break; + } default: callback({ message: 'Unknown provider.',