Skip to main content

How to know if user is a viewer on board view (client side)

  • September 6, 2022
  • 4 replies
  • 688 views

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

4 replies

Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • September 7, 2022

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


dari786
  • New Participant
  • September 7, 2022

I found this tough as well


  • Author
  • New Participant
  • September 22, 2022

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.


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • September 22, 2022

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