Good way to allow users to build their own user roles

I need my users to be able to control the app roles themselves. In other words, I do not want to keep giving permissions per user. Once i give the app to my users - they will be able to add users as needed and give roles to them. Is that possible?

Solved Solved
0 5 210
1 ACCEPTED SOLUTION

@Tiger
Something like thisโ€ฆ


ROLES TABLE


Column Name Column Type Base Type Key? Initial Value App Formula Valid_If Suggested Values Input Mode
USERROLE Enum Text - - ={โ€œOwnerโ€ , โ€œSuperadminโ€ , โ€œAdminโ€ , โ€œUserโ€} - Buttons
ACCESS TYPES Enumlist Text - - - =SWITCH([USERROLE],โ€œOwnerโ€,{โ€œALL_CHANGESโ€},โ€œSuperadminโ€,{โ€œADDS_AND_UPDATESโ€ , โ€œADDS_AND_DELETESโ€ , โ€œUPDATES_AND_DELETESโ€ , โ€œALL_CHANGESโ€},โ€œAdminโ€,{โ€œADDS_ONLYโ€ , โ€œUPDATES_ONLYโ€ , โ€œDELETES_ONLYโ€ , โ€œADDS_AND_UPDATESโ€ , โ€œADDS_AND_DELETESโ€ , โ€œUPDATES_AND_DELETESโ€},{โ€œADDS_ONLYโ€ , โ€œUPDATES_ONLYโ€ , โ€œADDS_AND_UPDATESโ€})

USERS TABLE


Column Name Column Type Base Type Key? Initial Value App Formula Valid_If Suggested Values Input Mode Source Table isPartOf?
USER_ID Text - =UNIQUEID() - - - - - -
FIRST NAME Text - - - - - - - - -
LAST NAME Text - - - - - - - - -
USEREMAIL Email - - - - - - - - -
USERROLE Ref - - - - - - Buttons ROLES -
PRIVILEGES Text - - - =[USERROLE].[ACCESS_TYPES] - - - - -

TABLE UPDATE MODE


LOOKUP(USEREMAIL(),"USERS","USEREMAIL","PRIVILEGES")

View solution in original post

5 REPLIES 5

In a way itโ€™s possible (from access privileges perspective only. As you are an account holder, you need to whitelist each user email via AppSheet Editorโ€™s Users Interface) if and only if you preset/predefine which userset can give/distribute which access privilege. Otherwise the app data will totally be out control.

Good point! I was going to go through each view, button etc and give permissions based on my user role table.

@Tiger
Something like thisโ€ฆ


ROLES TABLE


Column Name Column Type Base Type Key? Initial Value App Formula Valid_If Suggested Values Input Mode
USERROLE Enum Text - - ={โ€œOwnerโ€ , โ€œSuperadminโ€ , โ€œAdminโ€ , โ€œUserโ€} - Buttons
ACCESS TYPES Enumlist Text - - - =SWITCH([USERROLE],โ€œOwnerโ€,{โ€œALL_CHANGESโ€},โ€œSuperadminโ€,{โ€œADDS_AND_UPDATESโ€ , โ€œADDS_AND_DELETESโ€ , โ€œUPDATES_AND_DELETESโ€ , โ€œALL_CHANGESโ€},โ€œAdminโ€,{โ€œADDS_ONLYโ€ , โ€œUPDATES_ONLYโ€ , โ€œDELETES_ONLYโ€ , โ€œADDS_AND_UPDATESโ€ , โ€œADDS_AND_DELETESโ€ , โ€œUPDATES_AND_DELETESโ€},{โ€œADDS_ONLYโ€ , โ€œUPDATES_ONLYโ€ , โ€œADDS_AND_UPDATESโ€})

USERS TABLE


Column Name Column Type Base Type Key? Initial Value App Formula Valid_If Suggested Values Input Mode Source Table isPartOf?
USER_ID Text - =UNIQUEID() - - - - - -
FIRST NAME Text - - - - - - - - -
LAST NAME Text - - - - - - - - -
USEREMAIL Email - - - - - - - - -
USERROLE Ref - - - - - - Buttons ROLES -
PRIVILEGES Text - - - =[USERROLE].[ACCESS_TYPES] - - - - -

TABLE UPDATE MODE


LOOKUP(USEREMAIL(),"USERS","USEREMAIL","PRIVILEGES")

Thank you very muchโ€ฆ

@Tiger
Youโ€™re welcome. My sample is just to highlight the path. You can and need to expand the idea for your own needs and app requirements. Provided you struggle, you can post your questions anytime and we will be glad to help you to fixโ€™em.

Top Labels in this Space