Merge branch 'master' into patch-1

This commit is contained in:
Kevin Pfeifer 2020-05-13 16:03:06 +02:00 committed by GitHub
commit 7d005ca12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 6 deletions

View File

@ -125,7 +125,7 @@ module.exports = async (ctx, next) => {
The policy `isAdmin` located in `./api/restaurant/config/policies/isAdmin.js` will be executed before the `find` action in the `Restaurant.js` controller.
### Using a policy outside it's api
### Using a policy outside its api
To use a policy in another api you can reference it with the following syntax: `{apiName}.{policyName}`.

View File

@ -4,7 +4,7 @@ Strapi gives you the option to choose the most appropriate database for your pro
**MariaDB**. The following documentation covers how to install these databases locally (for development purposes) and on various hosted or cloud server solutions (for staging or production purposes).
::: tip
Deploying **Strapi** itself is covered in the [Deployment Guide](deployment.md).
Deploying **Strapi** itself is covered in the [Deployment Guide](../getting-started/deployment.md).
:::
## SQLite Installation

View File

@ -257,7 +257,7 @@ Then fill the informations:
- **Enable**: `ON`
- **Client ID**: 226437944084-o2mojv5i4lfnng9q8kq3jkf5v03avemk.apps.googleusercontent.com
- **Client ID**: aiTbMoiuJQflSBy6uQrfgsni
- **Client Secret**: aiTbMoiuJQflSBy6uQrfgsni
- **The redirect URL to your front-end app**: `http://localhost:3000/connect/google`
:::

View File

@ -22,7 +22,7 @@
"graphql-type-json": "0.3.1",
"graphql-type-long": "^0.1.1",
"koa-compose": "^4.1.0",
"lodash": "4.17.11",
"lodash": "4.17.12",
"pluralize": "^7.0.0",
"strapi-utils": "3.0.0-beta.20.3"
},

View File

@ -71,6 +71,8 @@ class PopUpForm extends React.Component {
return `${strapi.backendURL}/connect/instagram/callback`;
case 'vk':
return `${strapi.backendURL}/connect/vk/callback`;
case 'twitch':
return `${strapi.backendURL}/connect/twitch/callback`;
default: {
const value = get(this.props.values, 'callback', '');

View File

@ -86,6 +86,7 @@
"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.twitch.providerConfig.redirectURL": "The redirect URL to add in your Twitch 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",

View File

@ -84,6 +84,14 @@ module.exports = async () => {
callback: `${strapi.config.server.url}/auth/vk/callback`,
scope: ['email'],
},
twitch: {
enabled: false,
icon: 'twitch',
key: '',
secret: '',
callback: `${strapi.config.server.url}/auth/twitch/callback`,
scope: ['user:read:email'],
},
};
const prevGrantConfig = (await pluginStore.get({ key: 'grant' })) || {};
// store grant auth config to db

View File

@ -328,8 +328,7 @@ const getProfile = async (provider, query, callback) => {
vk.query()
.get('users.get')
.auth(access_token)
.qs({ id: query.raw.user_id, v: '5.013' })
.qs({ access_token, id: query.raw.user_id, v: '5.013' })
.request((err, res, body) => {
if (err) {
callback(err);
@ -342,6 +341,50 @@ const getProfile = async (provider, query, callback) => {
});
break;
}
case 'twitch': {
const twitch = purest({
provider: 'twitch',
config: {
twitch: {
'https://api.twitch.tv': {
__domain: {
auth: {
headers: {
Authorization: 'Bearer [0]',
'Client-ID': '[1]',
},
},
},
'helix/{endpoint}': {
__path: {
alias: '__default',
},
},
'oauth2/{endpoint}': {
__path: {
alias: 'oauth',
},
},
},
},
},
});
twitch
.get('users')
.auth(access_token, grant.twitch.key)
.request((err, res, body) => {
if (err) {
callback(err);
} else {
callback(null, {
username: body.data[0].login,
email: body.data[0].email,
});
}
});
break;
}
default:
callback({
message: 'Unknown provider.',