SnailyCAD / snaily-cadv4

💻 An open source Computer Aided Dispatch (CAD) for FiveM, this is a web based integration for communities who love police roleplaying and dispatching. Discord: https://discord.gg/eGnrPqEH7U
https://docs.snailycad.org/docs/getting-started
MIT License
147 stars 87 forks source link

Discord-assigned roles clash between each other #1730

Closed bartusek27 closed 1 year ago

bartusek27 commented 1 year ago

What version of Node.js are you using?

18

What operating system are you using?

Ubuntu

What version of SnailyCAD are you currently using?

1.64

Describe the Bug

Discord-assigned roles are not being added to the existing permissions of the user, but replaces all permissions. When I set for example roles for LEO and FD, and a user has both of them, it clashes between these two roles.

Expected Behavior

Proper way would be to add these roles to existing ones.

To Reproduce

Set Discord perms in CAD and give yourself multiple roles on Discord. After login, you might have only perms of one role or the other.

casperiv0 commented 1 year ago

So, to quickly understand, you're getting the permissions of only 1 of the roles that was assigned to the user, not all the permissions of all the roles assigned to the user?

@bartusek27

bartusek27 commented 1 year ago

By further testing, I have found out that it might be another issue or it could be linked to the first one. I have noticed that in the Discord Roles tab, the names of permissions inside the multi select box are a bit broken. I have noticed that sometimes, there is no translation inside the "tags" of permissions. That might be caused by multiplication of "Permissions." Being appended multiple times at the start of the string. That might cause the permission name to not work. I am not still sure why this happens, maybe because of switching the languages after saving the permissions with one language.

I hope it helps.

casperiv0 commented 1 year ago

By further testing, I have found out that it might be another issue or it could be linked to the first one. I have noticed that in the Discord Roles tab, the names of permissions inside the multi select box are a bit broken. I have noticed that sometimes, there is no translation inside the "tags" of permissions. That might be caused by multiplication of "Permissions." Being appended multiple times at the start of the string. That might cause the permission name to not work. I am not still sure why this happens, maybe because of switching the languages after saving the permissions with one language.

This isn't related to the problem. The translations might be outdated for the language you're using, however, under the hood, they use a unique name. Are you able to provide a video reproduction for this, please?

bartusek27 commented 1 year ago

By further testing, I have found out that it might be another issue or it could be linked to the first one. I have noticed that in the Discord Roles tab, the names of permissions inside the multi select box are a bit broken. I have noticed that sometimes, there is no translation inside the "tags" of permissions. That might be caused by multiplication of "Permissions." Being appended multiple times at the start of the string. That might cause the permission name to not work. I am not still sure why this happens, maybe because of switching the languages after saving the permissions with one language.

This isn't related to the problem. The translations might be outdated for the language you're using, however, under the hood, they use a unique name. Are you able to provide a video reproduction for this, please?

I don't think so... image image

This happened by saving it in my custom Czech language (saved alright), then switching to English, loading and saving the roles (everything looked okay) and refreshing the same page. After that, you could see distorted names. I checked the body of the request and it was sending exactly what is displayed.

Every save then appends Permission. to the string.

casperiv0 commented 1 year ago

This is now fixed! Thank you for the in-depth bug report!

bartusek27 commented 1 year ago

No worries, thank you for your time ;)