Error when create user or update from admin after override users permision

Hi!
I copy-paste the users-permissions from node_modules on extensions to override the register function
It works, but on the admin, when I try to modify the user I get this error

backend_1  | [2021-02-16T04:59:45.165Z] error TypeError: Cannot read property 'can' of undefined
backend_1  |     at Object.get isAllowed [as isAllowed] (/usr/src/app/node_modules/strapi-admin/services/permission/permissions-manager/index.js:22:25)
backend_1  |     at create (/usr/src/app/extensions/users-permissions/controllers/user/admin.js:60:13)
backend_1  |     at Object.create (/usr/src/app/extensions/users-permissions/controllers/User.js:35:12)

And when I try to update some user

backend_1  | [2021-02-16T05:05:01.861Z] error TypeError: Cannot read property 'cannot' of undefined
backend_1  |     at findEntityAndCheckPermissions (/usr/src/app/extensions/users-permissions/controllers/user/admin.js:35:18)
backend_1  |     at runMicrotasks (<anonymous>)
backend_1  |     at processTicksAndRejections (node:internal/process/task_queues:94:5)
backend_1  |     at async update (/usr/src/app/extensions/users-permissions/controllers/user/admin.js:159:34)

image

The only function that I modified was the register one

You should not copy the whole plugin into the extensions folder. Copy only the file that you want to modify.

2 Likes

What exactly you modified in register function?

Should I have like…
extensions/users-permissions/controllers/Auth.js?

I add functionality to the register function, control with invitation codes, default profile image, and following the user with x invitation code

1 Like

That works! thanks
image