Hi,
How to know if user is a viewer on board/dashboard view (client side- react) when app is loading?
Basically I would like to display a proper “missing permissions” message instead of the app display, in case it’s a viewer.
Code sample will be great.
Thanks
Roi
Hello there @Roi_kapah!
You could get the user ID by context using our SDK with something like this:
monday.get("context").then(res =>
{
console.log(res.data.user.id);
})
And then you can user another method to check the user type like this:
monday.api(`query {users(ids: ${THEUSERIDYOUGOT}){ is_admin is_guest is_view_only }}`).then(res =>
{
console.log(res)
});
I hope that helps!
Cheers,
Matias
I found this tough as well
Thanks @Matias.Monday , the code sample was very helpful.
How ever, it looks like no API calls can be made from the widget when the logged in user is a viewer, it looks like the context session id used for the calls not exist or missing permissions for API calls and an internal exception is being thrown.
Hello @Roi_kapah!
You are correct. This is because viewer users can not generate API tokens. So you will not receive that information from them.
Hope this helps!
Cheers,
Matias