I have some issues with the function in the title.
My site worked properly and I managed to use the roles on my site inside corvid code, but yesterday without any change in my code I experienced error.
I using my live site and inside the Site Monitor of the Wix Dashboard I see the following error in the returned promise:
“Not Found: the requested item no longer exists.”
my backend function:
export function getUserRoles(){
let user = wixUsersBackend.currentUser;
user.getRoles().then( (roles) =>{console.log(roles)}) //error in this line
}
The same situation!! I wrote specific request to the support and talked half an hour with local wix people but they have no answer yet.
For me it seems like the function .getRoles() is no longer available, which looks strange.
yes! It’s the same with getPricingPlans() unfortunately
GOS, it seems this problem is very common, right? Why not to answer to other people facing the same problem? It is realy hard to find out the solution in other threads while my original question about similar matter still unanswered
Hi everyone, hope the information from support would be useful in that context. I put a ticket about this matter and received the answer from support guy. He talks bit different things. He says that this functionality is no longer available but refers to the example in the documentation which is not changed during the last year - but we already know tgat something happened during the last few days. My feeling he guesses if example does not show the behaviour for backend it means that backend functionality should not be supported. Do not think so. Anyway, here is it.
…
Hi Alexey,
Thank you for getting back to Wix Customer Solutions.
I see you have created more than one ticket for this issue. I will respond to all your tickets here.
As you can see from our API here , getRoles() is currently part of the client side code and there’s no getRoles() function for wix-users-backend .
I can see that this is an important function for you and will forward your feedback to the relevant department, where it is weighed up and prioritized along with other requests within the development timeline
…
Yes that would make sense as the getRoles() and getPricingPlans() functions are only stipulated in the Wix Users API and not in the Wix Users Backend API.
So the code in the original post would have to be using the currentUser from the Wix Users API.
export function getUserRoles(){
let user = wixUsers.currentUser;
user.getRoles().then( (roles) =>{console.log(roles)})
}
Yes the Wix Users Backend API shows code example for getRoles through the backend, however take this as being incorrect and it needs changing urgently to reflect the actual and correct procedure.
https://www.wix.com/corvid/reference/wix-users-backend.html#currentUser
Hi,
omg, getting the roles on the client side fully destroys all the security principles. Js code running on the browser side is almost not protected and might be a subject of different kinds of attacks. Basically, roles are needed to select which part of functionality is available for connected client. But this functionality is provided by the backend, not by the frontend code! So taking the roles from the client side and sending them to the backend is realy unsecure.
I am pretty understand that all your examples show how to manage the roles ftom the client code but it should not be a reason to remove this functions from the backend
Epic fail - functionality and security.
Side note: If you’re not offering 2FA/MFA in 2020 at least for admin accounts, security is apparently not a priority anyway.
Totaly agree, and beside that, when you use them in router logic you’re double screwed. As i did
I also opened a ticket… Can’t understand this goes withtout even depricating those function and give us time to look for alternatives…
@givemeawhisky Removing getRoles() from backend does not make any sense. For what reason would they do that? It broken a lot of websites including mine. Now how do we check if a user is an Admin on the backend?
@samgong2015 , you could try the following workaround, although the ‘role’ property is being deprecated: get 'wixUsersBackend. currentUser ’ in the backend code. The ‘role’ property of the ‘user’ object should tell you ‘Admin’, ‘Member’ or ‘Visitor’. Not sure if it will work but might be worth a try .
https://www.wix.com/corvid/reference/wix-users-backend.html#currentUser
https://www.wix.com/corvid/reference/wix-users.User.html#role
@verbaldancing Thanks! Currently I just disabled the Admin check on my backend. Who knows when Wix will remove the ‘role’ property since it is already listed as ‘deprecated’. It is my first time to use Wix to build a website and have met several confusing things in the documentation. My general feeling is that the API/documentation of Wix Corvid is not of high quality compared to others.
They could remove the ‘roles’ propèrty indeed. If anyone would use it, you need a add a .catch error handler, and build in a mechanism to fall back on.
What is the response from Wix on this? I’m prototyping a site which has multiple roles (customer, case handler, admin) with functionality dependent on role. What is the ‘official’ method for securely working with different user roles?
hi all, should be fixed now!! please try and verify
Yes, it seems to be working now.