@strapi/plugin-users-permissions 4.1.3 → 4.1.4-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ function BoundRoute({ route }) {
23
23
  const colors = getMethodColor(route.method);
24
24
 
25
25
  return (
26
- <Stack size={2}>
26
+ <Stack spacing={2}>
27
27
  <Typography variant="delta" as="h3">
28
28
  {formatMessage({
29
29
  id: 'users-permissions.BoundRoute.title',
@@ -35,7 +35,7 @@ function BoundRoute({ route }) {
35
35
  .{action}
36
36
  </Typography>
37
37
  </Typography>
38
- <Stack horizontal hasRadius background="neutral0" borderColor="neutral200" size={0}>
38
+ <Stack horizontal hasRadius background="neutral0" borderColor="neutral200" spacing={0}>
39
39
  <MethodBox background={colors.background} borderColor={colors.border} padding={2}>
40
40
  <Typography fontWeight="bold" textColor={colors.text}>
41
41
  {method}
@@ -56,7 +56,7 @@ const FormModal = ({
56
56
  return (
57
57
  <Form>
58
58
  <ModalBody>
59
- <Stack size={1}>
59
+ <Stack spacing={1}>
60
60
  <Grid gap={5}>
61
61
  {layout.form.map(row => {
62
62
  return row.map(input => {
@@ -23,11 +23,11 @@ const Permissions = () => {
23
23
  });
24
24
 
25
25
  return (
26
- <Stack size={1}>
26
+ <Stack spacing={1}>
27
27
  {collapses.map((collapse, index) => (
28
28
  <Accordion
29
29
  expanded={collapse.isOpen}
30
- toggle={() => handleToggle(index)}
30
+ onToggle={() => handleToggle(index)}
31
31
  key={collapse.name}
32
32
  variant={index % 2 === 0 ? 'secondary' : undefined}
33
33
  >
@@ -30,14 +30,14 @@ const Policies = () => {
30
30
  style={{ minHeight: '100%' }}
31
31
  >
32
32
  {selectedAction ? (
33
- <Stack size={2}>
33
+ <Stack spacing={2}>
34
34
  {displayedRoutes.map((route, key) => (
35
35
  // eslint-disable-next-line react/no-array-index-key
36
36
  <BoundRoute key={key} route={route} />
37
37
  ))}
38
38
  </Stack>
39
39
  ) : (
40
- <Stack size={2}>
40
+ <Stack spacing={2}>
41
41
  <Typography variant="delta" as="h3">
42
42
  {formatMessage({
43
43
  id: 'users-permissions.Policies.header.title',
@@ -62,8 +62,8 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
62
62
  <UsersPermissionsProvider value={providerValue}>
63
63
  <Grid gap={0} shadow="filterShadow" hasRadius background="neutral0">
64
64
  <GridItem col={7} paddingTop={6} paddingBottom={6} paddingLeft={7} paddingRight={7}>
65
- <Stack size={6}>
66
- <Stack size={2}>
65
+ <Stack spacing={6}>
66
+ <Stack spacing={2}>
67
67
  <Typography variant="delta" as="h2">
68
68
  {formatMessage({
69
69
  id: getTrad('Plugins.header.title'),
@@ -168,7 +168,7 @@ const AdvancedSettingsPage = () => {
168
168
  paddingLeft={7}
169
169
  paddingRight={7}
170
170
  >
171
- <Stack size={4}>
171
+ <Stack spacing={4}>
172
172
  <Typography variant="delta" as="h2">
173
173
  {formatMessage({
174
174
  id: getTrad('Form.title.advancedSettings'),
@@ -1,7 +1,7 @@
1
1
  import * as yup from 'yup';
2
2
  import { translatedErrors } from '@strapi/helper-plugin';
3
3
 
4
- const URL_REGEX = new RegExp('(^$)|((https?://.*)(d*)/?(.*))');
4
+ const URL_REGEX = new RegExp('(^$)|((.+:\\/\\/.*)(d*)\\/?(.*))');
5
5
 
6
6
  const schema = yup.object().shape({
7
7
  email_confirmation_redirection: yup.mixed().when('email_confirmation', {
@@ -102,7 +102,7 @@ const EditPage = () => {
102
102
  })}
103
103
  />
104
104
  <ContentLayout>
105
- <Stack size={7}>
105
+ <Stack spacing={7}>
106
106
  <Box
107
107
  background="neutral0"
108
108
  hasRadius
@@ -112,7 +112,7 @@ const EditPage = () => {
112
112
  paddingLeft={7}
113
113
  paddingRight={7}
114
114
  >
115
- <Stack size={4}>
115
+ <Stack spacing={4}>
116
116
  <Typography variant="delta" as="h2">
117
117
  {formatMessage({
118
118
  id: getTrad('EditPage.form.roles'),
@@ -115,7 +115,7 @@ const EditPage = () => {
115
115
  }
116
116
  />
117
117
  <ContentLayout>
118
- <Stack size={7}>
118
+ <Stack spacing={7}>
119
119
  <Box
120
120
  background="neutral0"
121
121
  hasRadius
@@ -125,7 +125,7 @@ const EditPage = () => {
125
125
  paddingLeft={7}
126
126
  paddingRight={7}
127
127
  >
128
- <Stack size={4}>
128
+ <Stack spacing={4}>
129
129
  <Typography variant="delta" as="h2">
130
130
  {formatMessage({
131
131
  id: getTrad('EditPage.form.roles'),
@@ -12,7 +12,7 @@
12
12
  "EditForm.inputToggle.label.email-confirmation-redirection": "Redirection url",
13
13
  "EditForm.inputToggle.label.email-reset-password": "Reset password page",
14
14
  "EditForm.inputToggle.label.sign-up": "Enable sign-ups",
15
- "EditForm.inputToggle.placeholder.email-confirmation-redirection": "ex: https://yourfrontend.com/reset-password",
15
+ "EditForm.inputToggle.placeholder.email-confirmation-redirection": "ex: https://yourfrontend.com/confirmation-redirection",
16
16
  "EditForm.inputToggle.placeholder.email-reset-password": "ex: https://yourfrontend.com/reset-password",
17
17
  "EditPage.form.roles": "Role details",
18
18
  "Email.template.data.loaded": "Email templates has been loaded",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-users-permissions",
3
- "version": "4.1.3",
3
+ "version": "4.1.4-alpha.2",
4
4
  "description": "Protect your API with a full-authentication process based on JWT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@purest/providers": "^1.0.2",
31
- "@strapi/helper-plugin": "4.1.3",
32
- "@strapi/utils": "4.1.3",
31
+ "@strapi/helper-plugin": "4.1.4-alpha.2",
32
+ "@strapi/utils": "4.1.4-alpha.2",
33
33
  "bcryptjs": "2.4.3",
34
34
  "grant-koa": "5.4.8",
35
35
  "jsonwebtoken": "^8.1.0",
@@ -61,5 +61,5 @@
61
61
  "required": true,
62
62
  "kind": "plugin"
63
63
  },
64
- "gitHead": "8549f5aca34f2a72bb477a1b305260f39f271f4e"
64
+ "gitHead": "067d31a116cd5d31a0160073a09ade55ea4c95a9"
65
65
  }
@@ -0,0 +1,123 @@
1
+ 'use strict';
2
+
3
+ module.exports = baseURL => ({
4
+ email: {
5
+ enabled: true,
6
+ icon: 'envelope',
7
+ },
8
+ discord: {
9
+ enabled: false,
10
+ icon: 'discord',
11
+ key: '',
12
+ secret: '',
13
+ callback: `${baseURL}/discord/callback`,
14
+ scope: ['identify', 'email'],
15
+ },
16
+ facebook: {
17
+ enabled: false,
18
+ icon: 'facebook-square',
19
+ key: '',
20
+ secret: '',
21
+ callback: `${baseURL}/facebook/callback`,
22
+ scope: ['email'],
23
+ },
24
+ google: {
25
+ enabled: false,
26
+ icon: 'google',
27
+ key: '',
28
+ secret: '',
29
+ callback: `${baseURL}/google/callback`,
30
+ scope: ['email'],
31
+ },
32
+ github: {
33
+ enabled: false,
34
+ icon: 'github',
35
+ key: '',
36
+ secret: '',
37
+ callback: `${baseURL}/github/callback`,
38
+ scope: ['user', 'user:email'],
39
+ },
40
+ microsoft: {
41
+ enabled: false,
42
+ icon: 'windows',
43
+ key: '',
44
+ secret: '',
45
+ callback: `${baseURL}/microsoft/callback`,
46
+ scope: ['user.read'],
47
+ },
48
+ twitter: {
49
+ enabled: false,
50
+ icon: 'twitter',
51
+ key: '',
52
+ secret: '',
53
+ callback: `${baseURL}/twitter/callback`,
54
+ },
55
+ instagram: {
56
+ enabled: false,
57
+ icon: 'instagram',
58
+ key: '',
59
+ secret: '',
60
+ callback: `${baseURL}/instagram/callback`,
61
+ scope: ['user_profile'],
62
+ },
63
+ vk: {
64
+ enabled: false,
65
+ icon: 'vk',
66
+ key: '',
67
+ secret: '',
68
+ callback: `${baseURL}/vk/callback`,
69
+ scope: ['email'],
70
+ },
71
+ twitch: {
72
+ enabled: false,
73
+ icon: 'twitch',
74
+ key: '',
75
+ secret: '',
76
+ callback: `${baseURL}/twitch/callback`,
77
+ scope: ['user:read:email'],
78
+ },
79
+ linkedin: {
80
+ enabled: false,
81
+ icon: 'linkedin',
82
+ key: '',
83
+ secret: '',
84
+ callback: `${baseURL}/linkedin/callback`,
85
+ scope: ['r_liteprofile', 'r_emailaddress'],
86
+ },
87
+ cognito: {
88
+ enabled: false,
89
+ icon: 'aws',
90
+ key: '',
91
+ secret: '',
92
+ subdomain: 'my.subdomain.com',
93
+ callback: `${baseURL}/cognito/callback`,
94
+ scope: ['email', 'openid', 'profile'],
95
+ },
96
+ reddit: {
97
+ enabled: false,
98
+ icon: 'reddit',
99
+ key: '',
100
+ secret: '',
101
+ state: true,
102
+ callback: `${baseURL}/reddit/callback`,
103
+ scope: ['identity'],
104
+ },
105
+ auth0: {
106
+ enabled: false,
107
+ icon: '',
108
+ key: '',
109
+ secret: '',
110
+ subdomain: 'my-tenant.eu',
111
+ callback: `${baseURL}/auth0/callback`,
112
+ scope: ['openid', 'email', 'profile'],
113
+ },
114
+ cas: {
115
+ enabled: false,
116
+ icon: 'book',
117
+ key: '',
118
+ secret: '',
119
+ callback: `${baseURL}/cas/callback`,
120
+ scope: ['openid email'], // scopes should be space delimited
121
+ subdomain: 'my.subdomain.com/cas',
122
+ },
123
+ });
@@ -11,6 +11,7 @@ const _ = require('lodash');
11
11
  const urljoin = require('url-join');
12
12
  const uuid = require('uuid/v4');
13
13
  const { getService } = require('../utils');
14
+ const getGrantConfig = require('./grant-config');
14
15
 
15
16
  const usersPermissionsActions = require('./users-permissions-actions');
16
17
 
@@ -44,127 +45,7 @@ const initGrant = async pluginStore => {
44
45
  const apiPrefix = strapi.config.get('api.rest.prefix');
45
46
  const baseURL = urljoin(strapi.config.server.url, apiPrefix, 'auth');
46
47
 
47
- const grantConfig = {
48
- email: {
49
- enabled: true,
50
- icon: 'envelope',
51
- },
52
- discord: {
53
- enabled: false,
54
- icon: 'discord',
55
- key: '',
56
- secret: '',
57
- callback: `${baseURL}/discord/callback`,
58
- scope: ['identify', 'email'],
59
- },
60
- facebook: {
61
- enabled: false,
62
- icon: 'facebook-square',
63
- key: '',
64
- secret: '',
65
- callback: `${baseURL}/facebook/callback`,
66
- scope: ['email'],
67
- },
68
- google: {
69
- enabled: false,
70
- icon: 'google',
71
- key: '',
72
- secret: '',
73
- callback: `${baseURL}/google/callback`,
74
- scope: ['email'],
75
- },
76
- github: {
77
- enabled: false,
78
- icon: 'github',
79
- key: '',
80
- secret: '',
81
- callback: `${baseURL}/github/callback`,
82
- scope: ['user', 'user:email'],
83
- },
84
- microsoft: {
85
- enabled: false,
86
- icon: 'windows',
87
- key: '',
88
- secret: '',
89
- callback: `${baseURL}/microsoft/callback`,
90
- scope: ['user.read'],
91
- },
92
- twitter: {
93
- enabled: false,
94
- icon: 'twitter',
95
- key: '',
96
- secret: '',
97
- callback: `${baseURL}/twitter/callback`,
98
- },
99
- instagram: {
100
- enabled: false,
101
- icon: 'instagram',
102
- key: '',
103
- secret: '',
104
- callback: `${baseURL}/instagram/callback`,
105
- scope: ['user_profile'],
106
- },
107
- vk: {
108
- enabled: false,
109
- icon: 'vk',
110
- key: '',
111
- secret: '',
112
- callback: `${baseURL}/vk/callback`,
113
- scope: ['email'],
114
- },
115
- twitch: {
116
- enabled: false,
117
- icon: 'twitch',
118
- key: '',
119
- secret: '',
120
- callback: `${baseURL}/twitch/callback`,
121
- scope: ['user:read:email'],
122
- },
123
- linkedin: {
124
- enabled: false,
125
- icon: 'linkedin',
126
- key: '',
127
- secret: '',
128
- callback: `${baseURL}/linkedin/callback`,
129
- scope: ['r_liteprofile', 'r_emailaddress'],
130
- },
131
- cognito: {
132
- enabled: false,
133
- icon: 'aws',
134
- key: '',
135
- secret: '',
136
- subdomain: 'my.subdomain.com',
137
- callback: `${baseURL}/cognito/callback`,
138
- scope: ['email', 'openid', 'profile'],
139
- },
140
- reddit: {
141
- enabled: false,
142
- icon: 'reddit',
143
- key: '',
144
- secret: '',
145
- state: true,
146
- callback: `${baseURL}/reddit/callback`,
147
- scope: ['identity'],
148
- },
149
- auth0: {
150
- enabled: false,
151
- icon: '',
152
- key: '',
153
- secret: '',
154
- subdomain: 'my-tenant.eu',
155
- callback: `${baseURL}/auth0/callback`,
156
- scope: ['openid', 'email', 'profile'],
157
- },
158
- cas: {
159
- enabled: false,
160
- icon: 'book',
161
- key: '',
162
- secret: '',
163
- callback: `${baseURL}/cas/callback`,
164
- scope: ['openid email'], // scopes should be space delimited
165
- subdomain: 'my.subdomain.com/cas',
166
- },
167
- };
48
+ const grantConfig = getGrantConfig(baseURL);
168
49
 
169
50
  const prevGrantConfig = (await pluginStore.get({ key: 'grant' })) || {};
170
51
  // store grant auth config to db
@@ -137,7 +137,10 @@ module.exports = {
137
137
  throw new ValidationError('Incorrect code provided');
138
138
  }
139
139
 
140
- await getService('user').edit(user.id, { resetPasswordToken: null, password: params.password });
140
+ await getService('user').edit(user.id, {
141
+ resetPasswordToken: null,
142
+ password: params.password,
143
+ });
141
144
  // Update the user.
142
145
  ctx.send({
143
146
  jwt: getService('jwt').issue({ id: user.id }),
@@ -338,7 +341,7 @@ module.exports = {
338
341
  params.confirmed = true;
339
342
  }
340
343
 
341
- const user = await getService('user').add(params);
344
+ const user = await getService('user').add(params);
342
345
 
343
346
  const sanitizedUser = await sanitizeUser(user, ctx);
344
347
 
@@ -419,6 +422,13 @@ module.exports = {
419
422
  where: { email: params.email },
420
423
  });
421
424
 
425
+ if (!user) {
426
+ return ctx.send({
427
+ email: params.email,
428
+ sent: true,
429
+ });
430
+ }
431
+
422
432
  if (user.confirmed) {
423
433
  throw new ApplicationError('already.confirmed');
424
434
  }