@strapi/plugin-users-permissions 0.0.0-next.fd9757603c653ca239c45d6e28ab536d2dae0b39 → 0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231
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.
- package/.eslintignore +2 -1
- package/admin/src/components/BoundRoute/index.jsx +3 -3
- package/admin/src/components/FormModal/Input/index.jsx +33 -32
- package/admin/src/components/FormModal/index.jsx +58 -69
- package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.jsx +4 -3
- package/admin/src/components/Permissions/PermissionRow/SubCategory.jsx +13 -22
- package/admin/src/components/Permissions/index.jsx +27 -35
- package/admin/src/components/Permissions/reducer.js +1 -1
- package/admin/src/components/Policies/index.jsx +8 -6
- package/admin/src/components/UsersPermissions/index.jsx +15 -7
- package/admin/src/components/UsersPermissions/reducer.js +1 -1
- package/admin/src/index.js +17 -34
- package/admin/src/pages/AdvancedSettings/index.jsx +84 -129
- package/admin/src/pages/AdvancedSettings/utils/layout.js +20 -35
- package/admin/src/pages/AdvancedSettings/utils/schema.js +5 -2
- package/admin/src/pages/EmailTemplates/components/EmailForm.jsx +120 -140
- package/admin/src/pages/EmailTemplates/components/EmailTable.jsx +21 -18
- package/admin/src/pages/EmailTemplates/index.jsx +36 -62
- package/admin/src/pages/EmailTemplates/utils/schema.js +18 -6
- package/admin/src/pages/Providers/index.jsx +97 -112
- package/admin/src/pages/Providers/utils/forms.js +23 -11
- package/admin/src/pages/Roles/constants.js +3 -3
- package/admin/src/pages/Roles/hooks/usePlugins.js +4 -4
- package/admin/src/pages/Roles/index.jsx +10 -19
- package/admin/src/pages/Roles/pages/CreatePage.jsx +53 -58
- package/admin/src/pages/Roles/pages/EditPage.jsx +63 -68
- package/admin/src/pages/Roles/pages/ListPage/components/TableBody.jsx +28 -32
- package/admin/src/pages/Roles/pages/ListPage/index.jsx +79 -55
- package/admin/src/pluginId.js +2 -2
- package/admin/src/translations/en.json +1 -1
- package/admin/src/utils/prefixPluginTranslations.js +13 -0
- package/dist/admin/chunks/ar-BJwjobLp.js +45 -0
- package/dist/admin/chunks/ar-BJwjobLp.js.map +1 -0
- package/dist/admin/chunks/ar-G6bUGuUb.mjs +43 -0
- package/dist/admin/chunks/ar-G6bUGuUb.mjs.map +1 -0
- package/dist/admin/chunks/cs-Bu59JqhG.mjs +49 -0
- package/dist/admin/chunks/cs-Bu59JqhG.mjs.map +1 -0
- package/dist/admin/chunks/cs-uS_SIEo8.js +51 -0
- package/dist/admin/chunks/cs-uS_SIEo8.js.map +1 -0
- package/dist/admin/chunks/de-7MVMrqqI.js +63 -0
- package/dist/admin/chunks/de-7MVMrqqI.js.map +1 -0
- package/dist/admin/chunks/de-B81A69_5.mjs +61 -0
- package/dist/admin/chunks/de-B81A69_5.mjs.map +1 -0
- package/dist/admin/chunks/dk-BaelzvBE.mjs +85 -0
- package/dist/admin/chunks/dk-BaelzvBE.mjs.map +1 -0
- package/dist/admin/chunks/dk-DwCLGmy9.js +87 -0
- package/dist/admin/chunks/dk-DwCLGmy9.js.map +1 -0
- package/dist/admin/chunks/en-BhgCBe7M.mjs +85 -0
- package/dist/admin/chunks/en-BhgCBe7M.mjs.map +1 -0
- package/dist/admin/chunks/en-DwQjkHi_.js +87 -0
- package/dist/admin/chunks/en-DwQjkHi_.js.map +1 -0
- package/dist/admin/chunks/es-B0wXmvRj.mjs +85 -0
- package/dist/admin/chunks/es-B0wXmvRj.mjs.map +1 -0
- package/dist/admin/chunks/es-BOJOedG5.js +87 -0
- package/dist/admin/chunks/es-BOJOedG5.js.map +1 -0
- package/dist/admin/chunks/fr-BDNWCNs0.js +51 -0
- package/dist/admin/chunks/fr-BDNWCNs0.js.map +1 -0
- package/dist/admin/chunks/fr-CGYvGUXg.mjs +49 -0
- package/dist/admin/chunks/fr-CGYvGUXg.mjs.map +1 -0
- package/dist/admin/chunks/id-CNzbwFjA.mjs +61 -0
- package/dist/admin/chunks/id-CNzbwFjA.mjs.map +1 -0
- package/dist/admin/chunks/id-UqUPykHZ.js +63 -0
- package/dist/admin/chunks/id-UqUPykHZ.js.map +1 -0
- package/dist/admin/chunks/index-B-Z_z_qb.mjs +213 -0
- package/dist/admin/chunks/index-B-Z_z_qb.mjs.map +1 -0
- package/dist/admin/chunks/index-B2MJiSOD.mjs +279 -0
- package/dist/admin/chunks/index-B2MJiSOD.mjs.map +1 -0
- package/dist/admin/chunks/index-BPiDUOGt.js +471 -0
- package/dist/admin/chunks/index-BPiDUOGt.js.map +1 -0
- package/dist/admin/chunks/index-BtYUb_br.js +741 -0
- package/dist/admin/chunks/index-BtYUb_br.js.map +1 -0
- package/dist/admin/chunks/index-COXjHxFm.mjs +718 -0
- package/dist/admin/chunks/index-COXjHxFm.mjs.map +1 -0
- package/dist/admin/chunks/index-CkYplz_3.js +301 -0
- package/dist/admin/chunks/index-CkYplz_3.js.map +1 -0
- package/dist/admin/chunks/index-Cu2GvTiT.mjs +1516 -0
- package/dist/admin/chunks/index-Cu2GvTiT.mjs.map +1 -0
- package/dist/admin/chunks/index-D01zzG9y.js +1537 -0
- package/dist/admin/chunks/index-D01zzG9y.js.map +1 -0
- package/dist/admin/chunks/index-DAclA-0k.js +217 -0
- package/dist/admin/chunks/index-DAclA-0k.js.map +1 -0
- package/dist/admin/chunks/index-DVNIct2-.mjs +448 -0
- package/dist/admin/chunks/index-DVNIct2-.mjs.map +1 -0
- package/dist/admin/chunks/it-B2H2foTf.mjs +61 -0
- package/dist/admin/chunks/it-B2H2foTf.mjs.map +1 -0
- package/dist/admin/chunks/it-D5VuyoLU.js +63 -0
- package/dist/admin/chunks/it-D5VuyoLU.js.map +1 -0
- package/dist/admin/chunks/ja-C0z9d7L9.mjs +47 -0
- package/dist/admin/chunks/ja-C0z9d7L9.mjs.map +1 -0
- package/dist/admin/chunks/ja-MpqVsCgs.js +49 -0
- package/dist/admin/chunks/ja-MpqVsCgs.js.map +1 -0
- package/dist/admin/chunks/ko-Bm-grPSc.js +87 -0
- package/dist/admin/chunks/ko-Bm-grPSc.js.map +1 -0
- package/dist/admin/chunks/ko-CzUgzpeS.mjs +85 -0
- package/dist/admin/chunks/ko-CzUgzpeS.mjs.map +1 -0
- package/dist/admin/chunks/ms-CCacxjim.mjs +48 -0
- package/dist/admin/chunks/ms-CCacxjim.mjs.map +1 -0
- package/dist/admin/chunks/ms-D7eyBD5H.js +50 -0
- package/dist/admin/chunks/ms-D7eyBD5H.js.map +1 -0
- package/dist/admin/chunks/nl-BIOwAQtI.js +49 -0
- package/dist/admin/chunks/nl-BIOwAQtI.js.map +1 -0
- package/dist/admin/chunks/nl-DDC3nZW-.mjs +47 -0
- package/dist/admin/chunks/nl-DDC3nZW-.mjs.map +1 -0
- package/dist/admin/chunks/pl-D5BeNrg_.js +87 -0
- package/dist/admin/chunks/pl-D5BeNrg_.js.map +1 -0
- package/dist/admin/chunks/pl-XkS463rN.mjs +85 -0
- package/dist/admin/chunks/pl-XkS463rN.mjs.map +1 -0
- package/dist/admin/chunks/pt-BR-8cC7z8Km.mjs +43 -0
- package/dist/admin/chunks/pt-BR-8cC7z8Km.mjs.map +1 -0
- package/dist/admin/chunks/pt-BR-DxPBzQGx.js +45 -0
- package/dist/admin/chunks/pt-BR-DxPBzQGx.js.map +1 -0
- package/dist/admin/chunks/pt-DQpEvio8.mjs +47 -0
- package/dist/admin/chunks/pt-DQpEvio8.mjs.map +1 -0
- package/dist/admin/chunks/pt-kkCwzNvH.js +49 -0
- package/dist/admin/chunks/pt-kkCwzNvH.js.map +1 -0
- package/dist/admin/chunks/ru-BQ0gHmp3.js +87 -0
- package/dist/admin/chunks/ru-BQ0gHmp3.js.map +1 -0
- package/dist/admin/chunks/ru-nzL_7Mhg.mjs +85 -0
- package/dist/admin/chunks/ru-nzL_7Mhg.mjs.map +1 -0
- package/dist/admin/chunks/sk-Ddxc_tZA.mjs +49 -0
- package/dist/admin/chunks/sk-Ddxc_tZA.mjs.map +1 -0
- package/dist/admin/chunks/sk-nVwAPdYC.js +51 -0
- package/dist/admin/chunks/sk-nVwAPdYC.js.map +1 -0
- package/dist/admin/chunks/sv-BDfk2A-F.js +87 -0
- package/dist/admin/chunks/sv-BDfk2A-F.js.map +1 -0
- package/dist/admin/chunks/sv-By3RYpMG.mjs +85 -0
- package/dist/admin/chunks/sv-By3RYpMG.mjs.map +1 -0
- package/dist/admin/chunks/th-BtTtpHe2.js +61 -0
- package/dist/admin/chunks/th-BtTtpHe2.js.map +1 -0
- package/dist/admin/chunks/th-COl50vqb.mjs +59 -0
- package/dist/admin/chunks/th-COl50vqb.mjs.map +1 -0
- package/dist/admin/chunks/tr-80SJU6jg.mjs +84 -0
- package/dist/admin/chunks/tr-80SJU6jg.mjs.map +1 -0
- package/dist/admin/chunks/tr-Di-Nf7cT.js +86 -0
- package/dist/admin/chunks/tr-Di-Nf7cT.js.map +1 -0
- package/dist/admin/chunks/uk-CggQOx1l.js +50 -0
- package/dist/admin/chunks/uk-CggQOx1l.js.map +1 -0
- package/dist/admin/chunks/uk-D8JHuzch.mjs +48 -0
- package/dist/admin/chunks/uk-D8JHuzch.mjs.map +1 -0
- package/dist/admin/chunks/vi-69AF03Iv.mjs +49 -0
- package/dist/admin/chunks/vi-69AF03Iv.mjs.map +1 -0
- package/dist/admin/chunks/vi-D9cCsHsU.js +51 -0
- package/dist/admin/chunks/vi-D9cCsHsU.js.map +1 -0
- package/dist/admin/chunks/zh-BzSkqxo-.mjs +85 -0
- package/dist/admin/chunks/zh-BzSkqxo-.mjs.map +1 -0
- package/dist/admin/chunks/zh-BzWgJEzz.js +87 -0
- package/dist/admin/chunks/zh-BzWgJEzz.js.map +1 -0
- package/dist/admin/chunks/zh-Hans-CKqQbpsM.js +87 -0
- package/dist/admin/chunks/zh-Hans-CKqQbpsM.js.map +1 -0
- package/dist/admin/chunks/zh-Hans-DmDcSsp7.mjs +85 -0
- package/dist/admin/chunks/zh-Hans-DmDcSsp7.mjs.map +1 -0
- package/dist/admin/index.js +6 -3
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +1 -5
- package/dist/admin/index.mjs.map +1 -1
- package/dist/server/index.js +4766 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +4764 -0
- package/dist/server/index.mjs.map +1 -0
- package/package.json +31 -32
- package/rollup.config.mjs +52 -0
- package/server/bootstrap/index.js +18 -51
- package/server/content-types/user/index.js +0 -1
- package/server/controllers/auth.js +41 -60
- package/server/controllers/content-manager-user.js +28 -30
- package/server/controllers/role.js +17 -4
- package/server/controllers/user.js +8 -9
- package/server/controllers/validation/auth.js +104 -25
- package/server/graphql/types/index.js +1 -0
- package/server/graphql/types/me.js +1 -0
- package/server/graphql/types/user-input.js +20 -0
- package/server/middlewares/rateLimit.js +1 -1
- package/server/register.js +2 -2
- package/server/services/jwt.js +3 -3
- package/server/services/permission.js +3 -7
- package/server/services/providers-registry.js +468 -279
- package/server/services/providers.js +10 -5
- package/server/services/role.js +15 -13
- package/server/services/user.js +56 -19
- package/server/services/users-permissions.js +15 -13
- package/server/utils/index.d.ts +2 -1
- package/server/utils/sanitize/sanitizers.js +7 -3
- package/server/utils/sanitize/visitors/remove-user-relation-from-role-entities.js +2 -2
- package/admin/src/pages/Roles/pages/ListPage/utils/api.js +0 -30
- package/dist/_chunks/ar-MvD8Ghac.mjs +0 -44
- package/dist/_chunks/ar-MvD8Ghac.mjs.map +0 -1
- package/dist/_chunks/ar-t5qTFaAD.js +0 -44
- package/dist/_chunks/ar-t5qTFaAD.js.map +0 -1
- package/dist/_chunks/cs-BMuXwxA1.mjs +0 -50
- package/dist/_chunks/cs-BMuXwxA1.mjs.map +0 -1
- package/dist/_chunks/cs-I8N4u-Sd.js +0 -50
- package/dist/_chunks/cs-I8N4u-Sd.js.map +0 -1
- package/dist/_chunks/de-YTjtq89K.js +0 -62
- package/dist/_chunks/de-YTjtq89K.js.map +0 -1
- package/dist/_chunks/de-zs2qqc0W.mjs +0 -62
- package/dist/_chunks/de-zs2qqc0W.mjs.map +0 -1
- package/dist/_chunks/dk-HctVBMsG.mjs +0 -86
- package/dist/_chunks/dk-HctVBMsG.mjs.map +0 -1
- package/dist/_chunks/dk-TF-dWjzl.js +0 -86
- package/dist/_chunks/dk-TF-dWjzl.js.map +0 -1
- package/dist/_chunks/en-CE3wEy_c.mjs +0 -86
- package/dist/_chunks/en-CE3wEy_c.mjs.map +0 -1
- package/dist/_chunks/en-m608rMZx.js +0 -86
- package/dist/_chunks/en-m608rMZx.js.map +0 -1
- package/dist/_chunks/es-9381tih_.mjs +0 -86
- package/dist/_chunks/es-9381tih_.mjs.map +0 -1
- package/dist/_chunks/es-XBQsB8_9.js +0 -86
- package/dist/_chunks/es-XBQsB8_9.js.map +0 -1
- package/dist/_chunks/fr-6cz3U-IF.js +0 -50
- package/dist/_chunks/fr-6cz3U-IF.js.map +0 -1
- package/dist/_chunks/fr-CMSc77If.mjs +0 -50
- package/dist/_chunks/fr-CMSc77If.mjs.map +0 -1
- package/dist/_chunks/id-RJ934rq-.js +0 -62
- package/dist/_chunks/id-RJ934rq-.js.map +0 -1
- package/dist/_chunks/id-SDuyIkZa.mjs +0 -62
- package/dist/_chunks/id-SDuyIkZa.mjs.map +0 -1
- package/dist/_chunks/index-7cDy9OFu.mjs +0 -301
- package/dist/_chunks/index-7cDy9OFu.mjs.map +0 -1
- package/dist/_chunks/index-F7bt_caK.mjs +0 -1159
- package/dist/_chunks/index-F7bt_caK.mjs.map +0 -1
- package/dist/_chunks/index-H1mhyWXP.mjs +0 -385
- package/dist/_chunks/index-H1mhyWXP.mjs.map +0 -1
- package/dist/_chunks/index-Uclk5uc0.mjs +0 -250
- package/dist/_chunks/index-Uclk5uc0.mjs.map +0 -1
- package/dist/_chunks/index-cNS7FpQt.js +0 -320
- package/dist/_chunks/index-cNS7FpQt.js.map +0 -1
- package/dist/_chunks/index-e4dnRonE.js +0 -407
- package/dist/_chunks/index-e4dnRonE.js.map +0 -1
- package/dist/_chunks/index-oFjO2L1S.mjs +0 -615
- package/dist/_chunks/index-oFjO2L1S.mjs.map +0 -1
- package/dist/_chunks/index-rU_BkerL.js +0 -1191
- package/dist/_chunks/index-rU_BkerL.js.map +0 -1
- package/dist/_chunks/index-sm9u2cPw.js +0 -638
- package/dist/_chunks/index-sm9u2cPw.js.map +0 -1
- package/dist/_chunks/index-vLWD-DRR.js +0 -249
- package/dist/_chunks/index-vLWD-DRR.js.map +0 -1
- package/dist/_chunks/it-YhZOlM2X.js +0 -62
- package/dist/_chunks/it-YhZOlM2X.js.map +0 -1
- package/dist/_chunks/it-bvH7DgQo.mjs +0 -62
- package/dist/_chunks/it-bvH7DgQo.mjs.map +0 -1
- package/dist/_chunks/ja-o_-JPvQv.mjs +0 -48
- package/dist/_chunks/ja-o_-JPvQv.mjs.map +0 -1
- package/dist/_chunks/ja-xssHUXFv.js +0 -48
- package/dist/_chunks/ja-xssHUXFv.js.map +0 -1
- package/dist/_chunks/ko-C3mHUSJa.js +0 -86
- package/dist/_chunks/ko-C3mHUSJa.js.map +0 -1
- package/dist/_chunks/ko-XJbPSez_.mjs +0 -86
- package/dist/_chunks/ko-XJbPSez_.mjs.map +0 -1
- package/dist/_chunks/ms-II5Ea73J.mjs +0 -49
- package/dist/_chunks/ms-II5Ea73J.mjs.map +0 -1
- package/dist/_chunks/ms-d0hfg65Z.js +0 -49
- package/dist/_chunks/ms-d0hfg65Z.js.map +0 -1
- package/dist/_chunks/nl-TA7TfK_5.js +0 -48
- package/dist/_chunks/nl-TA7TfK_5.js.map +0 -1
- package/dist/_chunks/nl-vEy6TN0K.mjs +0 -48
- package/dist/_chunks/nl-vEy6TN0K.mjs.map +0 -1
- package/dist/_chunks/pl-0pUL9hdA.js +0 -86
- package/dist/_chunks/pl-0pUL9hdA.js.map +0 -1
- package/dist/_chunks/pl-2VowaFGt.mjs +0 -86
- package/dist/_chunks/pl-2VowaFGt.mjs.map +0 -1
- package/dist/_chunks/pt-BR-WNOhafR4.js +0 -44
- package/dist/_chunks/pt-BR-WNOhafR4.js.map +0 -1
- package/dist/_chunks/pt-BR-sS1Xp3Jt.mjs +0 -44
- package/dist/_chunks/pt-BR-sS1Xp3Jt.mjs.map +0 -1
- package/dist/_chunks/pt-Rf9W51IO.mjs +0 -48
- package/dist/_chunks/pt-Rf9W51IO.mjs.map +0 -1
- package/dist/_chunks/pt-guNR9Gax.js +0 -48
- package/dist/_chunks/pt-guNR9Gax.js.map +0 -1
- package/dist/_chunks/ru-X3BMXDds.js +0 -86
- package/dist/_chunks/ru-X3BMXDds.js.map +0 -1
- package/dist/_chunks/ru-qKHnd5or.mjs +0 -86
- package/dist/_chunks/ru-qKHnd5or.mjs.map +0 -1
- package/dist/_chunks/sk-NWPw1oTN.js +0 -50
- package/dist/_chunks/sk-NWPw1oTN.js.map +0 -1
- package/dist/_chunks/sk-_Ryr-eTT.mjs +0 -50
- package/dist/_chunks/sk-_Ryr-eTT.mjs.map +0 -1
- package/dist/_chunks/sv-76NnbB__.js +0 -86
- package/dist/_chunks/sv-76NnbB__.js.map +0 -1
- package/dist/_chunks/sv-BqzScFXS.mjs +0 -86
- package/dist/_chunks/sv-BqzScFXS.mjs.map +0 -1
- package/dist/_chunks/th-WsknMEpq.mjs +0 -60
- package/dist/_chunks/th-WsknMEpq.mjs.map +0 -1
- package/dist/_chunks/th-cbppX21D.js +0 -60
- package/dist/_chunks/th-cbppX21D.js.map +0 -1
- package/dist/_chunks/tr-6mm_Fmz7.js +0 -85
- package/dist/_chunks/tr-6mm_Fmz7.js.map +0 -1
- package/dist/_chunks/tr-_DB1F1GW.mjs +0 -85
- package/dist/_chunks/tr-_DB1F1GW.mjs.map +0 -1
- package/dist/_chunks/uk-sI2I1ogF.js +0 -49
- package/dist/_chunks/uk-sI2I1ogF.js.map +0 -1
- package/dist/_chunks/uk-yxMSQAwI.mjs +0 -49
- package/dist/_chunks/uk-yxMSQAwI.mjs.map +0 -1
- package/dist/_chunks/vi-A3zJxaiI.js +0 -50
- package/dist/_chunks/vi-A3zJxaiI.js.map +0 -1
- package/dist/_chunks/vi-xY0zCW3d.mjs +0 -50
- package/dist/_chunks/vi-xY0zCW3d.mjs.map +0 -1
- package/dist/_chunks/zh-72SpmFXa.js +0 -86
- package/dist/_chunks/zh-72SpmFXa.js.map +0 -1
- package/dist/_chunks/zh-Hans-ArWWtyP4.js +0 -86
- package/dist/_chunks/zh-Hans-ArWWtyP4.js.map +0 -1
- package/dist/_chunks/zh-Hans-E84cu4kP.mjs +0 -86
- package/dist/_chunks/zh-Hans-E84cu4kP.mjs.map +0 -1
- package/dist/_chunks/zh-OFeldzbX.mjs +0 -86
- package/dist/_chunks/zh-OFeldzbX.mjs.map +0 -1
- package/packup.config.ts +0 -22
- package/server/bootstrap/grant-config.js +0 -140
- package/strapi-server.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-users-permissions",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231",
|
|
4
4
|
"description": "Protect your API with a full-authentication process based on JWT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,14 +27,16 @@
|
|
|
27
27
|
"default": "./dist/admin/index.js"
|
|
28
28
|
},
|
|
29
29
|
"./strapi-server": {
|
|
30
|
-
"source": "./
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"source": "./server/index.js",
|
|
31
|
+
"import": "./dist/server/index.mjs",
|
|
32
|
+
"require": "./dist/server/index.js",
|
|
33
|
+
"default": "./dist/server/index.js"
|
|
33
34
|
},
|
|
34
35
|
"./package.json": "./package.json"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
|
-
"build": "
|
|
38
|
+
"build": "run -T npm-run-all clean build:code",
|
|
39
|
+
"build:code": "run -T rollup -c",
|
|
38
40
|
"clean": "run -T rimraf dist",
|
|
39
41
|
"lint": "run -T eslint .",
|
|
40
42
|
"test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
|
|
@@ -43,51 +45,49 @@
|
|
|
43
45
|
"test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
|
|
44
46
|
"test:unit": "run -T jest",
|
|
45
47
|
"test:unit:watch": "run -T jest --watch",
|
|
46
|
-
"watch": "
|
|
48
|
+
"watch": "run -T rollup -c -w"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"@strapi/design-system": "
|
|
50
|
-
"@strapi/
|
|
51
|
-
"@strapi/
|
|
52
|
-
"@strapi/utils": "0.0.0-next.fd9757603c653ca239c45d6e28ab536d2dae0b39",
|
|
51
|
+
"@strapi/design-system": "2.0.0-rc.16",
|
|
52
|
+
"@strapi/icons": "2.0.0-rc.16",
|
|
53
|
+
"@strapi/utils": "0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231",
|
|
53
54
|
"bcryptjs": "2.4.3",
|
|
54
|
-
"formik": "2.4.
|
|
55
|
-
"grant
|
|
56
|
-
"immer": "9.0.
|
|
55
|
+
"formik": "2.4.5",
|
|
56
|
+
"grant": "^5.4.8",
|
|
57
|
+
"immer": "9.0.21",
|
|
57
58
|
"jsonwebtoken": "9.0.0",
|
|
58
59
|
"jwk-to-pem": "2.0.5",
|
|
59
|
-
"koa": "2.
|
|
60
|
-
"koa2-ratelimit": "^1.1.
|
|
60
|
+
"koa": "2.15.2",
|
|
61
|
+
"koa2-ratelimit": "^1.1.3",
|
|
61
62
|
"lodash": "4.17.21",
|
|
62
63
|
"prop-types": "^15.8.1",
|
|
63
64
|
"purest": "4.0.2",
|
|
64
|
-
"react-intl": "6.
|
|
65
|
+
"react-intl": "6.6.2",
|
|
65
66
|
"react-query": "3.39.3",
|
|
66
|
-
"react-redux": "8.1.
|
|
67
|
+
"react-redux": "8.1.3",
|
|
67
68
|
"url-join": "4.0.1",
|
|
68
69
|
"yup": "0.32.9"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
|
-
"@strapi/
|
|
72
|
-
"@
|
|
73
|
-
"@testing-library/
|
|
74
|
-
"@testing-library/
|
|
75
|
-
"@testing-library/user-event": "14.4.3",
|
|
72
|
+
"@strapi/strapi": "0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231",
|
|
73
|
+
"@testing-library/dom": "10.1.0",
|
|
74
|
+
"@testing-library/react": "15.0.7",
|
|
75
|
+
"@testing-library/user-event": "14.5.2",
|
|
76
76
|
"msw": "1.3.0",
|
|
77
|
-
"react": "
|
|
78
|
-
"react-dom": "
|
|
79
|
-
"react-router-dom": "
|
|
80
|
-
"styled-components": "
|
|
77
|
+
"react": "18.3.1",
|
|
78
|
+
"react-dom": "18.3.1",
|
|
79
|
+
"react-router-dom": "6.22.3",
|
|
80
|
+
"styled-components": "6.1.8"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@strapi/strapi": "^
|
|
83
|
+
"@strapi/strapi": "^5.0.0",
|
|
84
84
|
"react": "^17.0.0 || ^18.0.0",
|
|
85
85
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
86
|
-
"react-router-dom": "^
|
|
87
|
-
"styled-components": "^
|
|
86
|
+
"react-router-dom": "^6.0.0",
|
|
87
|
+
"styled-components": "^6.0.0"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
|
-
"node": ">=18.0.0 <=
|
|
90
|
+
"node": ">=18.0.0 <=22.x.x",
|
|
91
91
|
"npm": ">=6.0.0"
|
|
92
92
|
},
|
|
93
93
|
"strapi": {
|
|
@@ -96,6 +96,5 @@
|
|
|
96
96
|
"description": "Protect your API with a full authentication process based on JWT. This plugin comes also with an ACL strategy that allows you to manage the permissions between the groups of users.",
|
|
97
97
|
"required": true,
|
|
98
98
|
"kind": "plugin"
|
|
99
|
-
}
|
|
100
|
-
"gitHead": "fd9757603c653ca239c45d6e28ab536d2dae0b39"
|
|
99
|
+
}
|
|
101
100
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineConfig } from 'rollup';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { basePlugins } from '../../../rollup.utils.mjs';
|
|
4
|
+
|
|
5
|
+
export default defineConfig([
|
|
6
|
+
{
|
|
7
|
+
input: path.join(import.meta.dirname, 'admin/src/index.js'),
|
|
8
|
+
external: (id) => !path.isAbsolute(id) && !id.startsWith('.'),
|
|
9
|
+
output: [
|
|
10
|
+
{
|
|
11
|
+
dir: path.join(import.meta.dirname, 'dist/admin'),
|
|
12
|
+
entryFileNames: '[name].js',
|
|
13
|
+
chunkFileNames: 'chunks/[name]-[hash].js',
|
|
14
|
+
exports: 'auto',
|
|
15
|
+
format: 'cjs',
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
dir: path.join(import.meta.dirname, 'dist/admin'),
|
|
20
|
+
entryFileNames: '[name].mjs',
|
|
21
|
+
chunkFileNames: 'chunks/[name]-[hash].mjs',
|
|
22
|
+
exports: 'auto',
|
|
23
|
+
format: 'esm',
|
|
24
|
+
sourcemap: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
plugins: [...basePlugins(import.meta.dirname)],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
input: path.join(import.meta.dirname, 'server/index.js'),
|
|
31
|
+
external: (id) => !path.isAbsolute(id) && !id.startsWith('.'),
|
|
32
|
+
output: [
|
|
33
|
+
{
|
|
34
|
+
dir: path.join(import.meta.dirname, 'dist/server'),
|
|
35
|
+
entryFileNames: '[name].js',
|
|
36
|
+
chunkFileNames: 'chunks/[name]-[hash].js',
|
|
37
|
+
exports: 'auto',
|
|
38
|
+
format: 'cjs',
|
|
39
|
+
sourcemap: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
dir: path.join(import.meta.dirname, 'dist/server'),
|
|
43
|
+
entryFileNames: '[name].mjs',
|
|
44
|
+
chunkFileNames: 'chunks/[name]-[hash].mjs',
|
|
45
|
+
exports: 'auto',
|
|
46
|
+
format: 'esm',
|
|
47
|
+
sourcemap: true,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
plugins: [...basePlugins(import.meta.dirname)],
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
@@ -9,25 +9,26 @@
|
|
|
9
9
|
*/
|
|
10
10
|
const crypto = require('crypto');
|
|
11
11
|
const _ = require('lodash');
|
|
12
|
-
const urljoin = require('url-join');
|
|
13
|
-
const { isArray } = require('lodash/fp');
|
|
14
12
|
const { getService } = require('../utils');
|
|
15
|
-
const getGrantConfig = require('./grant-config');
|
|
16
|
-
|
|
17
13
|
const usersPermissionsActions = require('./users-permissions-actions');
|
|
18
|
-
const userSchema = require('../content-types/user');
|
|
19
14
|
|
|
20
15
|
const initGrant = async (pluginStore) => {
|
|
21
|
-
const
|
|
22
|
-
|
|
16
|
+
const allProviders = getService('providers-registry').getAll();
|
|
17
|
+
|
|
18
|
+
const grantConfig = Object.entries(allProviders).reduce((acc, [name, provider]) => {
|
|
19
|
+
const { icon, enabled, grantConfig } = provider;
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
acc[name] = {
|
|
22
|
+
icon,
|
|
23
|
+
enabled,
|
|
24
|
+
...grantConfig,
|
|
25
|
+
};
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
25
28
|
|
|
26
29
|
const prevGrantConfig = (await pluginStore.get({ key: 'grant' })) || {};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// or we have added/deleted provider here.
|
|
30
|
-
if (!prevGrantConfig || !_.isEqual(_.keys(prevGrantConfig), _.keys(grantConfig))) {
|
|
30
|
+
|
|
31
|
+
if (!prevGrantConfig || !_.isEqual(prevGrantConfig, grantConfig)) {
|
|
31
32
|
// merge with the previous provider config.
|
|
32
33
|
_.keys(grantConfig).forEach((key) => {
|
|
33
34
|
if (key in prevGrantConfig) {
|
|
@@ -99,27 +100,6 @@ const initAdvancedOptions = async (pluginStore) => {
|
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
102
|
|
|
102
|
-
const userSchemaAdditions = () => {
|
|
103
|
-
const defaultSchema = Object.keys(userSchema.attributes);
|
|
104
|
-
const currentSchema = Object.keys(
|
|
105
|
-
strapi.contentTypes['plugin::users-permissions.user'].attributes
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
// Some dynamic fields may not have been initialized yet, so we need to ignore them
|
|
109
|
-
// TODO: we should have a global method for finding these
|
|
110
|
-
const ignoreDiffs = [
|
|
111
|
-
'createdBy',
|
|
112
|
-
'createdAt',
|
|
113
|
-
'updatedBy',
|
|
114
|
-
'updatedAt',
|
|
115
|
-
'publishedAt',
|
|
116
|
-
'strapi_stage',
|
|
117
|
-
'strapi_assignee',
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
return currentSchema.filter((key) => !(ignoreDiffs.includes(key) || defaultSchema.includes(key)));
|
|
121
|
-
};
|
|
122
|
-
|
|
123
103
|
module.exports = async ({ strapi }) => {
|
|
124
104
|
const pluginStore = strapi.store({ type: 'plugin', name: 'users-permissions' });
|
|
125
105
|
|
|
@@ -127,13 +107,13 @@ module.exports = async ({ strapi }) => {
|
|
|
127
107
|
await initEmails(pluginStore);
|
|
128
108
|
await initAdvancedOptions(pluginStore);
|
|
129
109
|
|
|
130
|
-
await strapi
|
|
131
|
-
|
|
132
|
-
|
|
110
|
+
await strapi
|
|
111
|
+
.service('admin::permission')
|
|
112
|
+
.actionProvider.registerMany(usersPermissionsActions.actions);
|
|
133
113
|
|
|
134
114
|
await getService('users-permissions').initialize();
|
|
135
115
|
|
|
136
|
-
if (!strapi.config.get('plugin
|
|
116
|
+
if (!strapi.config.get('plugin::users-permissions.jwtSecret')) {
|
|
137
117
|
if (process.env.NODE_ENV !== 'development') {
|
|
138
118
|
throw new Error(
|
|
139
119
|
`Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with \`crypto.randomBytes(16).toString('base64')\`).
|
|
@@ -143,7 +123,7 @@ For security reasons, prefer storing the secret in an environment variable and r
|
|
|
143
123
|
|
|
144
124
|
const jwtSecret = crypto.randomBytes(16).toString('base64');
|
|
145
125
|
|
|
146
|
-
strapi.config.set('plugin
|
|
126
|
+
strapi.config.set('plugin::users-permissions.jwtSecret', jwtSecret);
|
|
147
127
|
|
|
148
128
|
if (!process.env.JWT_SECRET) {
|
|
149
129
|
const envPath = process.env.ENV_PATH || '.env';
|
|
@@ -153,17 +133,4 @@ For security reasons, prefer storing the secret in an environment variable and r
|
|
|
153
133
|
);
|
|
154
134
|
}
|
|
155
135
|
}
|
|
156
|
-
|
|
157
|
-
// TODO v5: Remove this block of code and default allowedFields to empty array
|
|
158
|
-
if (!isArray(strapi.config.get('plugin.users-permissions.register.allowedFields'))) {
|
|
159
|
-
const modifications = userSchemaAdditions();
|
|
160
|
-
if (modifications.length > 0) {
|
|
161
|
-
// if there is a potential vulnerability, show a warning
|
|
162
|
-
strapi.log.warn(
|
|
163
|
-
`Users-permissions registration has defaulted to accepting the following additional user fields during registration: ${modifications.join(
|
|
164
|
-
','
|
|
165
|
-
)}`
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
136
|
};
|
|
@@ -11,9 +11,6 @@ const crypto = require('crypto');
|
|
|
11
11
|
const _ = require('lodash');
|
|
12
12
|
const { concat, compact, isArray } = require('lodash/fp');
|
|
13
13
|
const utils = require('@strapi/utils');
|
|
14
|
-
const {
|
|
15
|
-
contentTypes: { getNonWritableAttributes },
|
|
16
|
-
} = require('@strapi/utils');
|
|
17
14
|
const { getService } = require('../utils');
|
|
18
15
|
const {
|
|
19
16
|
validateCallbackBody,
|
|
@@ -25,17 +22,16 @@ const {
|
|
|
25
22
|
validateChangePasswordBody,
|
|
26
23
|
} = require('./validation/auth');
|
|
27
24
|
|
|
28
|
-
const { getAbsoluteAdminUrl, getAbsoluteServerUrl, sanitize } = utils;
|
|
29
25
|
const { ApplicationError, ValidationError, ForbiddenError } = utils.errors;
|
|
30
26
|
|
|
31
27
|
const sanitizeUser = (user, ctx) => {
|
|
32
28
|
const { auth } = ctx.state;
|
|
33
29
|
const userSchema = strapi.getModel('plugin::users-permissions.user');
|
|
34
30
|
|
|
35
|
-
return
|
|
31
|
+
return strapi.contentAPI.sanitize.output(user, userSchema, { auth });
|
|
36
32
|
};
|
|
37
33
|
|
|
38
|
-
module.exports = {
|
|
34
|
+
module.exports = ({ strapi }) => ({
|
|
39
35
|
async callback(ctx) {
|
|
40
36
|
const provider = ctx.params.provider || 'local';
|
|
41
37
|
const params = ctx.request.body;
|
|
@@ -55,7 +51,7 @@ module.exports = {
|
|
|
55
51
|
const { identifier } = params;
|
|
56
52
|
|
|
57
53
|
// Check if the user exists.
|
|
58
|
-
const user = await strapi.query('plugin::users-permissions.user').findOne({
|
|
54
|
+
const user = await strapi.db.query('plugin::users-permissions.user').findOne({
|
|
59
55
|
where: {
|
|
60
56
|
provider,
|
|
61
57
|
$or: [{ email: identifier.toLowerCase() }, { username: identifier }],
|
|
@@ -118,13 +114,17 @@ module.exports = {
|
|
|
118
114
|
throw new ApplicationError('You must be authenticated to reset your password');
|
|
119
115
|
}
|
|
120
116
|
|
|
121
|
-
const
|
|
117
|
+
const validations = strapi.config.get('plugin::users-permissions.validationRules');
|
|
122
118
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
const { currentPassword, password } = await validateChangePasswordBody(
|
|
120
|
+
ctx.request.body,
|
|
121
|
+
validations
|
|
126
122
|
);
|
|
127
123
|
|
|
124
|
+
const user = await strapi.db
|
|
125
|
+
.query('plugin::users-permissions.user')
|
|
126
|
+
.findOne({ where: { id: ctx.state.user.id } });
|
|
127
|
+
|
|
128
128
|
const validPassword = await getService('user').validatePassword(currentPassword, user.password);
|
|
129
129
|
|
|
130
130
|
if (!validPassword) {
|
|
@@ -144,15 +144,18 @@ module.exports = {
|
|
|
144
144
|
},
|
|
145
145
|
|
|
146
146
|
async resetPassword(ctx) {
|
|
147
|
+
const validations = strapi.config.get('plugin::users-permissions.validationRules');
|
|
148
|
+
|
|
147
149
|
const { password, passwordConfirmation, code } = await validateResetPasswordBody(
|
|
148
|
-
ctx.request.body
|
|
150
|
+
ctx.request.body,
|
|
151
|
+
validations
|
|
149
152
|
);
|
|
150
153
|
|
|
151
154
|
if (password !== passwordConfirmation) {
|
|
152
155
|
throw new ValidationError('Passwords do not match');
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
const user = await strapi
|
|
158
|
+
const user = await strapi.db
|
|
156
159
|
.query('plugin::users-permissions.user')
|
|
157
160
|
.findOne({ where: { resetPasswordToken: code } });
|
|
158
161
|
|
|
@@ -173,7 +176,7 @@ module.exports = {
|
|
|
173
176
|
},
|
|
174
177
|
|
|
175
178
|
async connect(ctx, next) {
|
|
176
|
-
const grant = require('grant
|
|
179
|
+
const grant = require('grant').koa();
|
|
177
180
|
|
|
178
181
|
const providers = await strapi
|
|
179
182
|
.store({ type: 'plugin', name: 'users-permissions', key: 'grant' })
|
|
@@ -237,7 +240,7 @@ module.exports = {
|
|
|
237
240
|
const advancedSettings = await pluginStore.get({ key: 'advanced' });
|
|
238
241
|
|
|
239
242
|
// Find the user by email.
|
|
240
|
-
const user = await strapi
|
|
243
|
+
const user = await strapi.db
|
|
241
244
|
.query('plugin::users-permissions.user')
|
|
242
245
|
.findOne({ where: { email: email.toLowerCase() } });
|
|
243
246
|
|
|
@@ -255,8 +258,8 @@ module.exports = {
|
|
|
255
258
|
resetPasswordSettings.message,
|
|
256
259
|
{
|
|
257
260
|
URL: advancedSettings.email_reset_password,
|
|
258
|
-
SERVER_URL:
|
|
259
|
-
ADMIN_URL:
|
|
261
|
+
SERVER_URL: strapi.config.get('server.absoluteUrl'),
|
|
262
|
+
ADMIN_URL: strapi.config.get('admin.absoluteUrl'),
|
|
260
263
|
USER: userInfo,
|
|
261
264
|
TOKEN: resetPasswordToken,
|
|
262
265
|
}
|
|
@@ -299,55 +302,32 @@ module.exports = {
|
|
|
299
302
|
throw new ApplicationError('Register action is currently disabled');
|
|
300
303
|
}
|
|
301
304
|
|
|
302
|
-
const { register } = strapi.config.get('plugin
|
|
305
|
+
const { register } = strapi.config.get('plugin::users-permissions');
|
|
303
306
|
const alwaysAllowedKeys = ['username', 'password', 'email'];
|
|
304
|
-
const userModel = strapi.contentTypes['plugin::users-permissions.user'];
|
|
305
|
-
const { attributes } = userModel;
|
|
306
|
-
|
|
307
|
-
const nonWritable = getNonWritableAttributes(userModel);
|
|
308
307
|
|
|
308
|
+
// Note that we intentionally do not filter allowedFields to allow a project to explicitly accept private or other Strapi field on registration
|
|
309
309
|
const allowedKeys = compact(
|
|
310
|
-
concat(
|
|
311
|
-
alwaysAllowedKeys,
|
|
312
|
-
isArray(register?.allowedFields)
|
|
313
|
-
? // Note that we do not filter allowedFields in case a user explicitly chooses to allow a private or otherwise omitted field on registration
|
|
314
|
-
register.allowedFields // if null or undefined, compact will remove it
|
|
315
|
-
: // to prevent breaking changes, if allowedFields is not set in config, we only remove private and known dangerous user schema fields
|
|
316
|
-
// TODO V5: allowedFields defaults to [] when undefined and remove this case
|
|
317
|
-
Object.keys(attributes).filter(
|
|
318
|
-
(key) =>
|
|
319
|
-
!nonWritable.includes(key) &&
|
|
320
|
-
!attributes[key].private &&
|
|
321
|
-
![
|
|
322
|
-
// many of these are included in nonWritable, but we'll list them again to be safe and since we're removing this code in v5 anyway
|
|
323
|
-
// Strapi user schema fields
|
|
324
|
-
'confirmed',
|
|
325
|
-
'blocked',
|
|
326
|
-
'confirmationToken',
|
|
327
|
-
'resetPasswordToken',
|
|
328
|
-
'provider',
|
|
329
|
-
'id',
|
|
330
|
-
'role',
|
|
331
|
-
// other Strapi fields that might be added
|
|
332
|
-
'createdAt',
|
|
333
|
-
'updatedAt',
|
|
334
|
-
'createdBy',
|
|
335
|
-
'updatedBy',
|
|
336
|
-
'publishedAt', // d&p
|
|
337
|
-
'strapi_reviewWorkflows_stage', // review workflows
|
|
338
|
-
].includes(key)
|
|
339
|
-
)
|
|
340
|
-
)
|
|
310
|
+
concat(alwaysAllowedKeys, isArray(register?.allowedFields) ? register.allowedFields : [])
|
|
341
311
|
);
|
|
342
312
|
|
|
313
|
+
// Check if there are any keys in requestBody that are not in allowedKeys
|
|
314
|
+
const invalidKeys = Object.keys(ctx.request.body).filter((key) => !allowedKeys.includes(key));
|
|
315
|
+
|
|
316
|
+
if (invalidKeys.length > 0) {
|
|
317
|
+
// If there are invalid keys, throw an error
|
|
318
|
+
throw new ValidationError(`Invalid parameters: ${invalidKeys.join(', ')}`);
|
|
319
|
+
}
|
|
320
|
+
|
|
343
321
|
const params = {
|
|
344
322
|
..._.pick(ctx.request.body, allowedKeys),
|
|
345
323
|
provider: 'local',
|
|
346
324
|
};
|
|
347
325
|
|
|
348
|
-
|
|
326
|
+
const validations = strapi.config.get('plugin::users-permissions.validationRules');
|
|
349
327
|
|
|
350
|
-
|
|
328
|
+
await validateRegisterBody(params, validations);
|
|
329
|
+
|
|
330
|
+
const role = await strapi.db
|
|
351
331
|
.query('plugin::users-permissions.role')
|
|
352
332
|
.findOne({ where: { type: settings.default_role } });
|
|
353
333
|
|
|
@@ -366,7 +346,7 @@ module.exports = {
|
|
|
366
346
|
],
|
|
367
347
|
};
|
|
368
348
|
|
|
369
|
-
const conflictingUserCount = await strapi.query('plugin::users-permissions.user').count({
|
|
349
|
+
const conflictingUserCount = await strapi.db.query('plugin::users-permissions.user').count({
|
|
370
350
|
where: { ...identifierFilter, provider },
|
|
371
351
|
});
|
|
372
352
|
|
|
@@ -375,7 +355,7 @@ module.exports = {
|
|
|
375
355
|
}
|
|
376
356
|
|
|
377
357
|
if (settings.unique_email) {
|
|
378
|
-
const conflictingUserCount = await strapi.query('plugin::users-permissions.user').count({
|
|
358
|
+
const conflictingUserCount = await strapi.db.query('plugin::users-permissions.user').count({
|
|
379
359
|
where: { ...identifierFilter },
|
|
380
360
|
});
|
|
381
361
|
|
|
@@ -400,7 +380,8 @@ module.exports = {
|
|
|
400
380
|
try {
|
|
401
381
|
await getService('user').sendConfirmationEmail(sanitizedUser);
|
|
402
382
|
} catch (err) {
|
|
403
|
-
|
|
383
|
+
strapi.log.error(err);
|
|
384
|
+
throw new ApplicationError('Error sending confirmation email');
|
|
404
385
|
}
|
|
405
386
|
|
|
406
387
|
return ctx.send({ user: sanitizedUser });
|
|
@@ -445,7 +426,7 @@ module.exports = {
|
|
|
445
426
|
async sendEmailConfirmation(ctx) {
|
|
446
427
|
const { email } = await validateSendEmailConfirmationBody(ctx.request.body);
|
|
447
428
|
|
|
448
|
-
const user = await strapi.query('plugin::users-permissions.user').findOne({
|
|
429
|
+
const user = await strapi.db.query('plugin::users-permissions.user').findOne({
|
|
449
430
|
where: { email: email.toLowerCase() },
|
|
450
431
|
});
|
|
451
432
|
|
|
@@ -468,4 +449,4 @@ module.exports = {
|
|
|
468
449
|
sent: true,
|
|
469
450
|
});
|
|
470
451
|
},
|
|
471
|
-
};
|
|
452
|
+
});
|
|
@@ -17,24 +17,25 @@ const ACTIONS = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const findEntityAndCheckPermissions = async (ability, action, model, id) => {
|
|
20
|
-
const
|
|
21
|
-
where: { id },
|
|
20
|
+
const doc = await strapi.service('plugin::content-manager.document-manager').findOne(id, model, {
|
|
22
21
|
populate: [`${CREATED_BY_ATTRIBUTE}.roles`],
|
|
23
22
|
});
|
|
24
23
|
|
|
25
|
-
if (_.isNil(
|
|
24
|
+
if (_.isNil(doc)) {
|
|
26
25
|
throw new NotFoundError();
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
const pm = strapi
|
|
28
|
+
const pm = strapi
|
|
29
|
+
.service('admin::permission')
|
|
30
|
+
.createPermissionsManager({ ability, action, model });
|
|
30
31
|
|
|
31
|
-
if (pm.ability.cannot(pm.action, pm.toSubject(
|
|
32
|
+
if (pm.ability.cannot(pm.action, pm.toSubject(doc))) {
|
|
32
33
|
throw new ForbiddenError();
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
const
|
|
36
|
+
const docWithoutCreatorRoles = _.omit(doc, `${CREATED_BY_ATTRIBUTE}.roles`);
|
|
36
37
|
|
|
37
|
-
return { pm,
|
|
38
|
+
return { pm, doc: docWithoutCreatorRoles };
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
module.exports = {
|
|
@@ -48,7 +49,7 @@ module.exports = {
|
|
|
48
49
|
|
|
49
50
|
const { email, username } = body;
|
|
50
51
|
|
|
51
|
-
const pm = strapi.admin
|
|
52
|
+
const pm = strapi.service('admin::permission').createPermissionsManager({
|
|
52
53
|
ability: userAbility,
|
|
53
54
|
action: ACTIONS.create,
|
|
54
55
|
model: userModel,
|
|
@@ -66,7 +67,7 @@ module.exports = {
|
|
|
66
67
|
|
|
67
68
|
await validateCreateUserBody(ctx.request.body);
|
|
68
69
|
|
|
69
|
-
const userWithSameUsername = await strapi
|
|
70
|
+
const userWithSameUsername = await strapi.db
|
|
70
71
|
.query('plugin::users-permissions.user')
|
|
71
72
|
.findOne({ where: { username } });
|
|
72
73
|
|
|
@@ -75,7 +76,7 @@ module.exports = {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
if (advanced.unique_email) {
|
|
78
|
-
const userWithSameEmail = await strapi
|
|
79
|
+
const userWithSameEmail = await strapi.db
|
|
79
80
|
.query('plugin::users-permissions.user')
|
|
80
81
|
.findOne({ where: { email: email.toLowerCase() } });
|
|
81
82
|
|
|
@@ -93,18 +94,11 @@ module.exports = {
|
|
|
93
94
|
|
|
94
95
|
user.email = _.toLower(user.email);
|
|
95
96
|
|
|
96
|
-
if (!user.role) {
|
|
97
|
-
const defaultRole = await strapi
|
|
98
|
-
.query('plugin::users-permissions.role')
|
|
99
|
-
.findOne({ where: { type: advanced.default_role } });
|
|
100
|
-
|
|
101
|
-
user.role = defaultRole.id;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
97
|
try {
|
|
105
98
|
const data = await strapi
|
|
106
|
-
.service('plugin::content-manager.
|
|
107
|
-
.create(
|
|
99
|
+
.service('plugin::content-manager.document-manager')
|
|
100
|
+
.create(userModel, { data: user });
|
|
101
|
+
|
|
108
102
|
const sanitizedData = await pm.sanitizeOutput(data, { action: ACTIONS.read });
|
|
109
103
|
|
|
110
104
|
ctx.created(sanitizedData);
|
|
@@ -118,7 +112,7 @@ module.exports = {
|
|
|
118
112
|
*/
|
|
119
113
|
|
|
120
114
|
async update(ctx) {
|
|
121
|
-
const { id } = ctx.params;
|
|
115
|
+
const { id: documentId } = ctx.params;
|
|
122
116
|
const { body } = ctx.request;
|
|
123
117
|
const { user: admin, userAbility } = ctx.state;
|
|
124
118
|
|
|
@@ -128,13 +122,14 @@ module.exports = {
|
|
|
128
122
|
|
|
129
123
|
const { email, username, password } = body;
|
|
130
124
|
|
|
131
|
-
const { pm,
|
|
125
|
+
const { pm, doc } = await findEntityAndCheckPermissions(
|
|
132
126
|
userAbility,
|
|
133
127
|
ACTIONS.edit,
|
|
134
128
|
userModel,
|
|
135
|
-
|
|
129
|
+
documentId
|
|
136
130
|
);
|
|
137
|
-
|
|
131
|
+
|
|
132
|
+
const user = doc;
|
|
138
133
|
|
|
139
134
|
await validateUpdateUserBody(ctx.request.body);
|
|
140
135
|
|
|
@@ -143,23 +138,24 @@ module.exports = {
|
|
|
143
138
|
}
|
|
144
139
|
|
|
145
140
|
if (_.has(body, 'username')) {
|
|
146
|
-
const userWithSameUsername = await strapi
|
|
141
|
+
const userWithSameUsername = await strapi.db
|
|
147
142
|
.query('plugin::users-permissions.user')
|
|
148
143
|
.findOne({ where: { username } });
|
|
149
144
|
|
|
150
|
-
if (userWithSameUsername && _.toString(userWithSameUsername.id) !== _.toString(id)) {
|
|
145
|
+
if (userWithSameUsername && _.toString(userWithSameUsername.id) !== _.toString(user.id)) {
|
|
151
146
|
throw new ApplicationError('Username already taken');
|
|
152
147
|
}
|
|
153
148
|
}
|
|
154
149
|
|
|
155
150
|
if (_.has(body, 'email') && advancedConfigs.unique_email) {
|
|
156
|
-
const userWithSameEmail = await strapi
|
|
151
|
+
const userWithSameEmail = await strapi.db
|
|
157
152
|
.query('plugin::users-permissions.user')
|
|
158
153
|
.findOne({ where: { email: _.toLower(email) } });
|
|
159
154
|
|
|
160
|
-
if (userWithSameEmail && _.toString(userWithSameEmail.id) !== _.toString(id)) {
|
|
155
|
+
if (userWithSameEmail && _.toString(userWithSameEmail.id) !== _.toString(user.id)) {
|
|
161
156
|
throw new ApplicationError('Email already taken');
|
|
162
157
|
}
|
|
158
|
+
|
|
163
159
|
body.email = _.toLower(body.email);
|
|
164
160
|
}
|
|
165
161
|
|
|
@@ -167,8 +163,10 @@ module.exports = {
|
|
|
167
163
|
const updateData = _.omit({ ...sanitizedData, updatedBy: admin.id }, 'createdBy');
|
|
168
164
|
|
|
169
165
|
const data = await strapi
|
|
170
|
-
.service('plugin::content-manager.
|
|
171
|
-
.update(
|
|
166
|
+
.service('plugin::content-manager.document-manager')
|
|
167
|
+
.update(documentId, userModel, {
|
|
168
|
+
data: updateData,
|
|
169
|
+
});
|
|
172
170
|
|
|
173
171
|
ctx.body = await pm.sanitizeOutput(data, { action: ACTIONS.read });
|
|
174
172
|
},
|