@strapi/plugin-users-permissions 4.0.5 → 4.1.0

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.
@@ -28,12 +28,12 @@ const Input = ({
28
28
 
29
29
  const label = formatMessage(
30
30
  { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
31
- { ...intlLabel.values }
31
+ { provider: providerToEditName, ...intlLabel.values }
32
32
  );
33
33
  const hint = description
34
34
  ? formatMessage(
35
35
  { id: description.id, defaultMessage: description.defaultMessage },
36
- { ...description.values }
36
+ { provider: providerToEditName, ...description.values }
37
37
  )
38
38
  : '';
39
39
 
@@ -23,9 +23,6 @@ const keyLabel = { id: getTrad('PopUpForm.Providers.key.label'), defaultMessage:
23
23
  const hintLabel = {
24
24
  id: getTrad('PopUpForm.Providers.redirectURL.label'),
25
25
  defaultMessage: 'The redirect URL to add in your {provider} application configurations',
26
- values: {
27
- provider: 'VK',
28
- },
29
26
  };
30
27
  const textPlaceholder = {
31
28
  id: getTrad('PopUpForm.Providers.key.placeholder'),
@@ -12,8 +12,19 @@
12
12
  "EditForm.inputToggle.label.email-confirmation-redirection": "Omdirigerings URL",
13
13
  "EditForm.inputToggle.label.email-reset-password": "Nulstil kodeord side",
14
14
  "EditForm.inputToggle.label.sign-up": "Aktivér oprettelser",
15
+ "EditForm.inputToggle.placeholder.email-confirmation-redirection": "f.eks. https://hjemmeside.dk/nulstil-kodeord",
16
+ "EditForm.inputToggle.placeholder.email-reset-password": "f.eks. https://hjemmeside.dk/nulstil-kodeord",
17
+ "EditPage.form.roles": "Rolle detaljer",
18
+ "Email.template.data.loaded": "E-mail skabeloner er hentet",
15
19
  "Email.template.email_confirmation": "E-mail adresse bekræftelse",
20
+ "Email.template.form.edit.label": "Redigér en skabelon",
16
21
  "Email.template.reset_password": "Nulstil kodeord",
22
+ "Email.template.table.action.label": "handling",
23
+ "Email.template.table.icon.label": "ikon",
24
+ "Email.template.table.name.label": "navn",
25
+ "Form.advancedSettings.data.loaded": "Avancerede indstillinger hentet",
26
+ "Form.save": "Gem",
27
+ "Form.title.advancedSettings": "Indstillinger",
17
28
  "HeaderNav.link.advancedSettings": "Advancerede indstillinger",
18
29
  "HeaderNav.link.emailTemplates": "E-mail skabeloner",
19
30
  "HeaderNav.link.providers": "Udbydere",
@@ -31,36 +42,21 @@
31
42
  "PopUpForm.Email.options.from.name.placeholder": "John Doe",
32
43
  "PopUpForm.Email.options.message.label": "Besked",
33
44
  "PopUpForm.Email.options.object.label": "Emne",
45
+ "PopUpForm.Email.options.object.placeholder": "Bekræft venligst din e-mail adresse for %APP_NAME%",
34
46
  "PopUpForm.Email.options.response_email.label": "Svar e-mail",
35
47
  "PopUpForm.Email.options.response_email.placeholder": "johndoe@gmail.com",
36
48
  "PopUpForm.Providers.enabled.description": "Hvis deaktiveret, kan brugere ikke bruge denne udbyder.",
37
49
  "PopUpForm.Providers.enabled.label": "Aktivér",
38
50
  "PopUpForm.Providers.key.label": "Klient ID",
39
51
  "PopUpForm.Providers.key.placeholder": "TEKST",
40
- "PopUpForm.Providers.secret.label": "Klient hemmelighed",
41
- "PopUpForm.Providers.secret.placeholder": "TEKST",
42
- "PopUpForm.header.edit.email-templates": "Redigér e-mail skabeloner",
43
- "PopUpForm.header.edit.providers": "Redigér udbydere",
44
- "notification.success.submit": "Indstillingerne er blevet opdateret",
45
- "plugin.description.long": "Beskyt din API med fuld godkendelse med JWT. Dette plugin kommer også med en ACL strategi som tillader dig at håndtere rettigeheder mellem grupper af brugere.",
46
- "plugin.description.short": "Beskyt din API med fuld godkendelse med JWT",
47
- "plugin.name": "Roller & rettigheder",
48
- "EditForm.inputToggle.placeholder.email-confirmation-redirection": "f.eks. https://hjemmeside.dk/nulstil-kodeord",
49
- "EditForm.inputToggle.placeholder.email-reset-password": "f.eks. https://hjemmeside.dk/nulstil-kodeord",
50
- "EditPage.form.roles": "Rolle detaljer",
51
- "Email.template.data.loaded": "E-mail skabeloner er hentet",
52
- "Email.template.form.edit.label": "Redigér en skabelon",
53
- "Email.template.table.action.label": "handling",
54
- "Email.template.table.icon.label": "ikon",
55
- "Email.template.table.name.label": "navn",
56
- "Form.advancedSettings.data.loaded": "Avancerede indstillinger hentet",
57
- "Form.save": "Gem",
58
- "Form.title.advancedSettings": "Indstillinger",
59
- "PopUpForm.Email.options.object.placeholder": "Bekræft venligst din e-mail adresse for %APP_NAME%",
60
52
  "PopUpForm.Providers.redirectURL.front-end.label": "Omstillings URL til din font-end app",
61
53
  "PopUpForm.Providers.redirectURL.label": "Omstillings URL som tilføjes til din {provider} applikation konfigurationer",
54
+ "PopUpForm.Providers.secret.label": "Klient hemmelighed",
55
+ "PopUpForm.Providers.secret.placeholder": "TEKST",
62
56
  "PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
63
57
  "PopUpForm.Providers.subdomain.placeholder": "mit.subdomain.dk",
58
+ "PopUpForm.header.edit.email-templates": "Redigér e-mail skabeloner",
59
+ "PopUpForm.header.edit.providers": "Redigér udbydere",
64
60
  "Providers.data.loaded": "Providers hentet",
65
61
  "Providers.disabled": "Deaktiveret",
66
62
  "Providers.enabled": "Aktiveret",
@@ -86,7 +82,11 @@
86
82
  "components.Input.error.validation.regex": "Værdien stemmer ikke overens med regex.",
87
83
  "components.Input.error.validation.required": "Værdien er påkrævet.",
88
84
  "components.Input.error.validation.unique": "Værdien er allerede brugt.",
85
+ "notification.success.submit": "Indstillingerne er blevet opdateret",
89
86
  "page.title": "Indstillinger - Roller",
87
+ "plugin.description.long": "Beskyt din API med fuld godkendelse med JWT. Dette plugin kommer også med en ACL strategi som tillader dig at håndtere rettigeheder mellem grupper af brugere.",
88
+ "plugin.description.short": "Beskyt din API med fuld godkendelse med JWT",
89
+ "plugin.name": "Roller & rettigheder",
90
90
  "popUpWarning.button.cancel": "Annuller",
91
91
  "popUpWarning.button.confirm": "Bekræft",
92
92
  "popUpWarning.title": "Bekræft venligst",
@@ -1,94 +1,94 @@
1
1
  {
2
- "BoundRoute.title": "라우트(bound route)",
3
- "EditForm.inputSelect.description.role": "인증된 사용자에 선택한 역할(role)을 부여합니다.",
4
- "EditForm.inputSelect.label.role": "인증된 사용자의 기본 역할(role)",
5
- "EditForm.inputToggle.description.email": "사용자가 동일한 이메일 주소를 사용해 여러 계정을 만들지 못하게 합니다.",
6
- "EditForm.inputToggle.description.email-confirmation": "(ON)이 활성화되면, 새로 가입하는 사용자는 인증 메일을 받게됩니다.",
7
- "EditForm.inputToggle.description.email-confirmation-redirection": "이메일 인증완료 후 리다이렉트 될 주소",
8
- "EditForm.inputToggle.description.email-reset-password": "애플리케이션의 비밀번호 재설정 URL 페이지",
9
- "EditForm.inputToggle.description.sign-up": "비활성(OFF)일 경우, 등록 프로세스를 금지합니다. 사용하는 프로바이더(provider)에 관계 없이 누구도 가입할 수 없습니다.",
10
- "EditForm.inputToggle.label.email": "이메일 주소 당 하나의 계정",
11
- "EditForm.inputToggle.label.email-confirmation": "이메일 인증 활성화",
12
- "EditForm.inputToggle.label.email-confirmation-redirection": "리다이렉션 url",
13
- "EditForm.inputToggle.label.email-reset-password": "패스워드 재설정 페이지",
14
- "EditForm.inputToggle.label.sign-up": "사용자 등록",
15
- "EditForm.inputToggle.placeholder.email-confirmation-redirection": "예: https://yourfrontend.com/reset-password",
16
- "EditForm.inputToggle.placeholder.email-reset-password": "예: https://yourfrontend.com/reset-password",
17
- "EditPage.form.roles": "역할 상세정보",
18
- "Email.template.data.loaded": "이메일 템플릿을 불러왔습니다.",
19
- "Email.template.email_confirmation": "이메일 주소 확인",
20
- "Email.template.form.edit.label": "템플릿 수정",
21
- "Email.template.reset_password": "비밀번호 재설정",
22
- "Email.template.table.action.label": "action",
23
- "Email.template.table.icon.label": "icon",
24
- "Email.template.table.name.label": "name",
25
- "Form.advancedSettings.data.loaded": "고급 설정 정보를 불러왔습니다.",
26
- "Form.save": "저장",
27
- "Form.title.advancedSettings": "설정",
28
- "HeaderNav.link.advancedSettings": "고급 설정",
29
- "HeaderNav.link.emailTemplates": "이메일 템플릿",
30
- "HeaderNav.link.providers": "프로바이더(Providers)",
31
- "HeaderNav.link.roles": "역할(Roles) & 권한(Permissions)",
32
- "Plugin.permissions.plugins.description": "{name} 플러그인에서 허용할 액션을 설정합니다.",
33
- "Plugins.header.description": "라우트(route)에 연결된 액션만 표시됩니다.",
34
- "Plugins.header.title": "권한(Permissions)",
35
- "Policies.header.hint": "애플리케이션 또는 플러그인을 선택하고 항목을 클릭하면 바인딩 된 경로를 표시할 수 있습니다.",
36
- "Policies.header.title": "고급 설정",
37
- "PopUpForm.Email.email_templates.inputDescription": "이메일 템플릿 문법은 이 {link}를 확인하세요.",
38
- "PopUpForm.Email.link.documentation": "check out our documentation.",
39
- "PopUpForm.Email.options.from.email.label": "보내는 이메일",
40
- "PopUpForm.Email.options.from.email.placeholder": "kai@doe.com",
41
- "PopUpForm.Email.options.from.name.label": "보내는 사람",
42
- "PopUpForm.Email.options.from.name.placeholder": "Kai Doe",
43
- "PopUpForm.Email.options.message.label": "내용",
44
- "PopUpForm.Email.options.object.label": "제목",
45
- "PopUpForm.Email.options.object.placeholder": "Please confirm your email address for %APP_NAME%",
46
- "PopUpForm.Email.options.response_email.label": "응답받을 이메일",
47
- "PopUpForm.Email.options.response_email.placeholder": "kai@doe.com",
48
- "PopUpForm.Providers.enabled.description": "사용하지 않을 경우 이 프로바이더(provider) 기능을 이용할 수 없습니다.",
49
- "PopUpForm.Providers.enabled.label": "사용",
50
- "PopUpForm.Providers.key.label": "클라이언트 ID(Client ID)",
51
- "PopUpForm.Providers.key.placeholder": "텍스트",
52
- "PopUpForm.Providers.redirectURL.front-end.label": "프론트엔드 애플리케이션 리다이렉트 URL",
53
- "PopUpForm.Providers.redirectURL.label": "{provider} 애플리케이션 구성에 추가할 리디렉션 URL",
54
- "PopUpForm.Providers.secret.label": "클라이언트 시크릿(Client Secret)",
55
- "PopUpForm.Providers.secret.placeholder": "텍스트",
56
- "PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
57
- "PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
58
- "PopUpForm.header.edit.email-templates": "이메일 템플릿 수정",
59
- "PopUpForm.header.edit.providers": "프로바이더 수정",
60
- "Providers.data.loaded": "프로바이더를 불러왔습니다.",
61
- "Providers.disabled": "사용 안함",
62
- "Providers.enabled": "사용중",
63
- "Providers.image": "이미지",
64
- "Providers.name": "이름",
65
- "Providers.settings": "설정",
66
- "Providers.status": "상태",
67
- "Roles.description": "설명",
68
- "Roles.empty": "아직 역할이 없습니다.",
69
- "Roles.empty.search": "검색과 일치하는 역할이 없습니다.",
70
- "Roles.name": "이름",
71
- "Roles.users": "사용자",
72
- "Settings.roles.deleted": "Role deleted",
73
- "Settings.roles.edited": "Role edited",
74
- "Settings.section-label": "사용자 & 권한 플러그인",
75
- "components.Input.error.validation.email": "유효하지 않은 이메일입니다.",
76
- "components.Input.error.validation.json": "JSON 형식과 일치하지 않습니다.",
77
- "components.Input.error.validation.max": "값이 너무 큽니다.",
78
- "components.Input.error.validation.maxLength": "값이 너무 깁니다.",
79
- "components.Input.error.validation.min": "값이 너무 작습니다.",
80
- "components.Input.error.validation.minLength": "값이 너무 짧습니다.",
81
- "components.Input.error.validation.minSupMax": "이보다 클 수 없습니다.",
82
- "components.Input.error.validation.regex": "값이 정규식과 일치하지 않습니다.",
83
- "components.Input.error.validation.required": "필수 항목입니다.",
84
- "components.Input.error.validation.unique": "이 값은 이미 사용되고 있습니다.",
85
- "notification.success.submit": "설정을 업데이트했습니다.",
86
- "page.title": "설정 - 역할",
87
- "plugin.description.long": "JWT 기반의 인증 프로세스로 API를 보호하세요. 이 플러그인에서 사용자 그룹간 권한을 관리할 수 있는 ACL 전략도 설정할 수 있습니다.",
88
- "plugin.description.short": "JWT 기반의 인증 프로세스로 API를 보호하세요.",
89
- "plugin.name": "역할(roles) & 권한(permissions)",
90
- "popUpWarning.button.cancel": "취소",
91
- "popUpWarning.button.confirm": "확인",
92
- "popUpWarning.title": "Please confirm",
93
- "popUpWarning.warning.cancel": "수정 사항을 취소하시겠습니까?"
94
- }
2
+ "BoundRoute.title": "라우트(bound route)",
3
+ "EditForm.inputSelect.description.role": "인증된 사용자에 선택한 역할(role)을 부여합니다.",
4
+ "EditForm.inputSelect.label.role": "인증된 사용자의 기본 역할(role)",
5
+ "EditForm.inputToggle.description.email": "사용자가 동일한 이메일 주소를 사용해 여러 계정을 만들지 못하게 합니다.",
6
+ "EditForm.inputToggle.description.email-confirmation": "(ON)이 활성화되면, 새로 가입하는 사용자는 인증 메일을 받게됩니다.",
7
+ "EditForm.inputToggle.description.email-confirmation-redirection": "이메일 인증완료 후 리다이렉트 될 주소",
8
+ "EditForm.inputToggle.description.email-reset-password": "애플리케이션의 비밀번호 재설정 URL 페이지",
9
+ "EditForm.inputToggle.description.sign-up": "비활성(OFF)일 경우, 등록 프로세스를 금지합니다. 사용하는 프로바이더(provider)에 관계 없이 누구도 가입할 수 없습니다.",
10
+ "EditForm.inputToggle.label.email": "이메일 주소 당 하나의 계정",
11
+ "EditForm.inputToggle.label.email-confirmation": "이메일 인증 활성화",
12
+ "EditForm.inputToggle.label.email-confirmation-redirection": "리다이렉션 url",
13
+ "EditForm.inputToggle.label.email-reset-password": "패스워드 재설정 페이지",
14
+ "EditForm.inputToggle.label.sign-up": "사용자 등록",
15
+ "EditForm.inputToggle.placeholder.email-confirmation-redirection": "예: https://yourfrontend.com/reset-password",
16
+ "EditForm.inputToggle.placeholder.email-reset-password": "예: https://yourfrontend.com/reset-password",
17
+ "EditPage.form.roles": "역할 상세정보",
18
+ "Email.template.data.loaded": "이메일 템플릿을 불러왔습니다.",
19
+ "Email.template.email_confirmation": "이메일 주소 확인",
20
+ "Email.template.form.edit.label": "템플릿 수정",
21
+ "Email.template.reset_password": "비밀번호 재설정",
22
+ "Email.template.table.action.label": "action",
23
+ "Email.template.table.icon.label": "icon",
24
+ "Email.template.table.name.label": "name",
25
+ "Form.advancedSettings.data.loaded": "고급 설정 정보를 불러왔습니다.",
26
+ "Form.save": "저장",
27
+ "Form.title.advancedSettings": "설정",
28
+ "HeaderNav.link.advancedSettings": "고급 설정",
29
+ "HeaderNav.link.emailTemplates": "이메일 템플릿",
30
+ "HeaderNav.link.providers": "프로바이더(Providers)",
31
+ "HeaderNav.link.roles": "역할(Roles) & 권한(Permissions)",
32
+ "Plugin.permissions.plugins.description": "{name} 플러그인에서 허용할 액션을 설정합니다.",
33
+ "Plugins.header.description": "라우트(route)에 연결된 액션만 표시됩니다.",
34
+ "Plugins.header.title": "권한(Permissions)",
35
+ "Policies.header.hint": "애플리케이션 또는 플러그인을 선택하고 항목을 클릭하면 바인딩 된 경로를 표시할 수 있습니다.",
36
+ "Policies.header.title": "고급 설정",
37
+ "PopUpForm.Email.email_templates.inputDescription": "이메일 템플릿 문법은 이 {link}를 확인하세요.",
38
+ "PopUpForm.Email.link.documentation": "check out our documentation.",
39
+ "PopUpForm.Email.options.from.email.label": "보내는 이메일",
40
+ "PopUpForm.Email.options.from.email.placeholder": "kai@doe.com",
41
+ "PopUpForm.Email.options.from.name.label": "보내는 사람",
42
+ "PopUpForm.Email.options.from.name.placeholder": "Kai Doe",
43
+ "PopUpForm.Email.options.message.label": "내용",
44
+ "PopUpForm.Email.options.object.label": "제목",
45
+ "PopUpForm.Email.options.object.placeholder": "Please confirm your email address for %APP_NAME%",
46
+ "PopUpForm.Email.options.response_email.label": "응답받을 이메일",
47
+ "PopUpForm.Email.options.response_email.placeholder": "kai@doe.com",
48
+ "PopUpForm.Providers.enabled.description": "사용하지 않을 경우 이 프로바이더(provider) 기능을 이용할 수 없습니다.",
49
+ "PopUpForm.Providers.enabled.label": "사용",
50
+ "PopUpForm.Providers.key.label": "클라이언트 ID(Client ID)",
51
+ "PopUpForm.Providers.key.placeholder": "텍스트",
52
+ "PopUpForm.Providers.redirectURL.front-end.label": "프론트엔드 애플리케이션 리다이렉트 URL",
53
+ "PopUpForm.Providers.redirectURL.label": "{provider} 애플리케이션 구성에 추가할 리디렉션 URL",
54
+ "PopUpForm.Providers.secret.label": "클라이언트 시크릿(Client Secret)",
55
+ "PopUpForm.Providers.secret.placeholder": "텍스트",
56
+ "PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
57
+ "PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
58
+ "PopUpForm.header.edit.email-templates": "이메일 템플릿 수정",
59
+ "PopUpForm.header.edit.providers": "프로바이더 수정",
60
+ "Providers.data.loaded": "프로바이더를 불러왔습니다.",
61
+ "Providers.disabled": "사용 안함",
62
+ "Providers.enabled": "사용중",
63
+ "Providers.image": "이미지",
64
+ "Providers.name": "이름",
65
+ "Providers.settings": "설정",
66
+ "Providers.status": "상태",
67
+ "Roles.description": "설명",
68
+ "Roles.empty": "아직 역할이 없습니다.",
69
+ "Roles.empty.search": "검색과 일치하는 역할이 없습니다.",
70
+ "Roles.name": "이름",
71
+ "Roles.users": "사용자",
72
+ "Settings.roles.deleted": "Role deleted",
73
+ "Settings.roles.edited": "Role edited",
74
+ "Settings.section-label": "사용자 & 권한 플러그인",
75
+ "components.Input.error.validation.email": "유효하지 않은 이메일입니다.",
76
+ "components.Input.error.validation.json": "JSON 형식과 일치하지 않습니다.",
77
+ "components.Input.error.validation.max": "값이 너무 큽니다.",
78
+ "components.Input.error.validation.maxLength": "값이 너무 깁니다.",
79
+ "components.Input.error.validation.min": "값이 너무 작습니다.",
80
+ "components.Input.error.validation.minLength": "값이 너무 짧습니다.",
81
+ "components.Input.error.validation.minSupMax": "이보다 클 수 없습니다.",
82
+ "components.Input.error.validation.regex": "값이 정규식과 일치하지 않습니다.",
83
+ "components.Input.error.validation.required": "필수 항목입니다.",
84
+ "components.Input.error.validation.unique": "이 값은 이미 사용되고 있습니다.",
85
+ "notification.success.submit": "설정을 업데이트했습니다.",
86
+ "page.title": "설정 - 역할",
87
+ "plugin.description.long": "JWT 기반의 인증 프로세스로 API를 보호하세요. 이 플러그인에서 사용자 그룹간 권한을 관리할 수 있는 ACL 전략도 설정할 수 있습니다.",
88
+ "plugin.description.short": "JWT 기반의 인증 프로세스로 API를 보호하세요.",
89
+ "plugin.name": "역할(roles) & 권한(permissions)",
90
+ "popUpWarning.button.cancel": "취소",
91
+ "popUpWarning.button.confirm": "확인",
92
+ "popUpWarning.title": "Please confirm",
93
+ "popUpWarning.warning.cancel": "수정 사항을 취소하시겠습니까?"
94
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-users-permissions",
3
- "version": "4.0.5",
3
+ "version": "4.1.0",
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.0.5",
32
- "@strapi/utils": "4.0.5",
31
+ "@strapi/helper-plugin": "4.1.0",
32
+ "@strapi/utils": "4.1.0",
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": "45020eee065af8917011cc43398f95c4c624d6ad"
64
+ "gitHead": "d4273d81fbeec230b5734375e43a5f1f1f2a0231"
65
65
  }
@@ -8,6 +8,7 @@
8
8
  * run jobs, or perform some special logic.
9
9
  */
10
10
  const _ = require('lodash');
11
+ const urljoin = require('url-join');
11
12
  const uuid = require('uuid/v4');
12
13
  const { getService } = require('../utils');
13
14
 
@@ -32,13 +33,16 @@ module.exports = async ({ strapi }) => {
32
33
 
33
34
  if (!process.env.JWT_SECRET) {
34
35
  strapi.fs.appendFile(process.env.ENV_PATH || '.env', `JWT_SECRET=${jwtSecret}\n`);
36
+ strapi.log.info(
37
+ 'The Users & Permissions plugin automatically generated a jwt secret and stored it in your .env file under the name JWT_SECRET.'
38
+ );
35
39
  }
36
40
  }
37
41
  };
38
42
 
39
43
  const initGrant = async pluginStore => {
40
44
  const apiPrefix = strapi.config.get('api.rest.prefix');
41
- const baseURL = `${strapi.config.server.url}/${apiPrefix}/auth`;
45
+ const baseURL = urljoin(strapi.config.server.url, apiPrefix, 'auth');
42
46
 
43
47
  const grantConfig = {
44
48
  email: {
@@ -137,13 +137,8 @@ module.exports = {
137
137
  throw new ValidationError('Incorrect code provided');
138
138
  }
139
139
 
140
- const password = await getService('user').hashPassword({ password: params.password });
141
-
140
+ await getService('user').edit(user.id, { resetPasswordToken: null, password: params.password });
142
141
  // Update the user.
143
- await strapi
144
- .query('plugin::users-permissions.user')
145
- .update({ where: { id: user.id }, data: { resetPasswordToken: null, password } });
146
-
147
142
  ctx.send({
148
143
  jwt: getService('jwt').issue({ id: user.id }),
149
144
  user: await sanitizeUser(user, ctx),
@@ -188,7 +183,10 @@ module.exports = {
188
183
  }
189
184
 
190
185
  // Ability to pass OAuth callback dynamically
191
- grantConfig[provider].callback = _.get(ctx, 'query.callback') || grantConfig[provider].callback;
186
+ grantConfig[provider].callback =
187
+ _.get(ctx, 'query.callback') ||
188
+ _.get(ctx, 'session.grant.dynamic.callback') ||
189
+ grantConfig[provider].callback;
192
190
  grantConfig[provider].redirect_uri = getService('providers').buildRedirectUri(provider);
193
191
 
194
192
  return grant(grantConfig)(ctx, next);
@@ -322,7 +320,6 @@ module.exports = {
322
320
  }
323
321
 
324
322
  params.role = role.id;
325
- params.password = await getService('user').hashPassword(params);
326
323
 
327
324
  const user = await strapi.query('plugin::users-permissions.user').findOne({
328
325
  where: { email: params.email },
@@ -341,7 +338,7 @@ module.exports = {
341
338
  params.confirmed = true;
342
339
  }
343
340
 
344
- const user = await strapi.query('plugin::users-permissions.user').create({ data: params });
341
+ const user = await getService('user').add(params);
345
342
 
346
343
  const sanitizedUser = await sanitizeUser(user, ctx);
347
344
 
@@ -364,8 +361,11 @@ module.exports = {
364
361
  } catch (err) {
365
362
  if (_.includes(err.message, 'username')) {
366
363
  throw new ApplicationError('Username already taken');
367
- } else {
364
+ } else if (_.includes(err.message, 'email')) {
368
365
  throw new ApplicationError('Email already taken');
366
+ } else {
367
+ strapi.log.error(err);
368
+ throw new ApplicationError('An error occurred during account creation');
369
369
  }
370
370
  }
371
371
  },
@@ -21,8 +21,6 @@ module.exports = ({ strapi }) => ({
21
21
  }
22
22
 
23
23
  token = parts[1];
24
- } else if (ctx.query.access_token) {
25
- token = ctx.query.access_token;
26
24
  } else {
27
25
  return null;
28
26
  }
@@ -35,13 +35,10 @@ module.exports = ({ strapi }) => ({
35
35
  * @return {Promise}
36
36
  */
37
37
  async add(values) {
38
- if (values.password) {
39
- values.password = await getService('user').hashPassword(values);
40
- }
41
-
42
- return strapi
43
- .query('plugin::users-permissions.user')
44
- .create({ data: values, populate: ['role'] });
38
+ return strapi.entityService.create('plugin::users-permissions.user', {
39
+ data: values,
40
+ populate: ['role'],
41
+ });
45
42
  },
46
43
 
47
44
  /**
@@ -51,10 +48,6 @@ module.exports = ({ strapi }) => ({
51
48
  * @return {Promise}
52
49
  */
53
50
  async edit(userId, params = {}) {
54
- if (params.password) {
55
- params.password = await getService('user').hashPassword(params);
56
- }
57
-
58
51
  return strapi.entityService.update('plugin::users-permissions.user', userId, {
59
52
  data: params,
60
53
  populate: ['role'],
@@ -87,21 +80,13 @@ module.exports = ({ strapi }) => ({
87
80
  return strapi.query('plugin::users-permissions.user').findMany({ where: params, populate });
88
81
  },
89
82
 
90
- hashPassword(user = {}) {
91
- return new Promise((resolve, reject) => {
92
- if (!user.password || this.isHashed(user.password)) {
93
- resolve(null);
94
- } else {
95
- bcrypt.hash(`${user.password}`, 10, (err, hash) => {
96
- if (err) {
97
- return reject(err);
98
- }
99
- resolve(hash);
100
- });
101
- }
102
- });
83
+ /**
84
+ * Promise to remove a/an user.
85
+ * @return {Promise}
86
+ */
87
+ async remove(params) {
88
+ return strapi.query('plugin::users-permissions.user').delete({ where: params });
103
89
  },
104
-
105
90
  isHashed(password) {
106
91
  if (typeof password !== 'string' || !password) {
107
92
  return false;
@@ -110,14 +95,6 @@ module.exports = ({ strapi }) => ({
110
95
  return password.split('$').length === 4;
111
96
  },
112
97
 
113
- /**
114
- * Promise to remove a/an user.
115
- * @return {Promise}
116
- */
117
- async remove(params) {
118
- return strapi.query('plugin::users-permissions.user').delete({ where: params });
119
- },
120
-
121
98
  validatePassword(password, hash) {
122
99
  return bcrypt.compare(password, hash);
123
100
  },
@@ -67,40 +67,25 @@ const authenticate = async ctx => {
67
67
  const verify = async (auth, config) => {
68
68
  const { credentials: user } = auth;
69
69
 
70
- // public accesss
71
- if (!user) {
72
- // test against public role
73
- const publicPermissions = await strapi.query('plugin::users-permissions.permission').findMany({
74
- where: {
75
- role: { type: 'public' },
76
- },
77
- });
78
-
79
- const allowedActions = map('action', publicPermissions);
80
-
81
- // A non authenticated user cannot access routes that do not have a scope
82
- if (!config.scope) {
70
+ if (!config.scope) {
71
+ if (!user) {
72
+ // A non authenticated user cannot access routes that do not have a scope
83
73
  throw new UnauthorizedError();
74
+ } else {
75
+ // An authenticated user can access non scoped routes
76
+ return;
84
77
  }
85
-
86
- const isAllowed = castArray(config.scope).every(scope => allowedActions.includes(scope));
87
-
88
- if (!isAllowed) {
89
- throw new ForbiddenError();
90
- }
91
-
92
- return;
93
78
  }
94
79
 
95
- const permissions = await strapi.query('plugin::users-permissions.permission').findMany({
96
- where: { role: user.role.id },
97
- });
80
+ let allowedActions = auth.allowedActions;
98
81
 
99
- const allowedActions = map('action', permissions);
82
+ if (!allowedActions) {
83
+ const permissions = await strapi.query('plugin::users-permissions.permission').findMany({
84
+ where: { role: user ? user.role.id : { type: 'public' } },
85
+ });
100
86
 
101
- // An authenticated user can access non scoped routes
102
- if (!config.scope) {
103
- return;
87
+ allowedActions = map('action', permissions);
88
+ auth.allowedActions = allowedActions;
104
89
  }
105
90
 
106
91
  const isAllowed = castArray(config.scope).every(scope => allowedActions.includes(scope));
@@ -108,12 +93,6 @@ const verify = async (auth, config) => {
108
93
  if (!isAllowed) {
109
94
  throw new ForbiddenError();
110
95
  }
111
-
112
- // TODO: if we need to keep policies for u&p execution
113
- // Execute the policies.
114
- // if (permission.policy) {
115
- // return await strapi.plugin('users-permissions').policy(permission.policy)(ctx, next);
116
- // }
117
96
  };
118
97
 
119
98
  module.exports = {