How can I design a super administrator with user permissions? When developing a member management system, you want to have the permissions of a super administrator to perform any operations without knowing how to distinguish it from other users. now you want to make the program accessible by default as a super administrator, then other users can judge based on the permissions passed in, but are worried about poor writing. other users can also obtain the permissions of the Super Administrator, or you can only use a lot of if else to determine whether the super administrator privilege is too troublesome. how can you design it better?
Reply to discussion (solution)
There are no differences between super administrators and users in the algorithm itself
You only grant different permissions to different users. Obviously, the super administrator is granted all permissions.
For access by default as a super administrator, that is, the permissions you set are not "allowed", but "forbidden"
There are no differences between super administrators and users in the algorithm itself
You only grant different permissions to different users. Obviously, the super administrator is granted all permissions.
For access by default as a super administrator, that is, the permissions you set are not "allowed", but "forbidden"
According to my understanding, the so-called permission control is essentially different from if/else, right? Is there any other method for the big edition?
There are no differences between super administrators and users in the algorithm itself
You only grant different permissions to different users. Obviously, the super administrator is granted all permissions.
For access by default as a super administrator, that is, the permissions you set are not "allowed", but "forbidden"
For example, if I have an activity page, ordinary members can only see their own activities, while Super administrators can see all created activities, I don't know how to design a page that is not simply forbidden access.
You have read range permission.
You can set two permission bits: the primary key, and other
Super Administrator: 00
User: 01