css - How do permissions and the like operate when developing a backend system?
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 13:32:20
0
3
647

For example, the display of the menu bar, the operation of buttons, etc. Only consider the operations required by the front end. . Thanks

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
伊谢尔伦

If we follow role-menu, the front-end must save the relationship between role and menu (let’s call it roleMenuList for now, of course, this list is usually obtained from the background), which can be a list with pure ID,

roleMenuList: [1,2,3,4,5]

When rendering and traversing the menu on the page, it is judged whether the menu item id exists in roleMenuList. If so, it will be displayed, otherwise it will be hidden.

For button permissions, an identifier similar to id is also needed to identify this element. You can use custom attributes, such as

<button authorCode="myButtion"></button>

Get a button permission list from the backend. The element that contains myButtion needs to be hidden or disabled, for example

buttonAuthorList = [
    { code: 'myBution', to: 'disabled'},
    { code: 'hisBution', to: 'hidden'}
    ...
    ]

After recognizing the code identifier, perform the corresponding operations. Of course, the ones mentioned here are just simple examples, and the attributes still need to be carefully and strictly defined~

Ty80

You can refer to windows: Account -> Role -> Permissions;
Permissions can be whitelisted/blacklisted or used together;
Back-end verification, the front-end will tailor and process it based on the role and permissions list behind the certificate.

黄舟

I have made a php+mysql comment function before. Edit, delete and other buttons are not displayed for non-current users. It is relatively simple.

if (isset($_SESSION['id'])) {
                    if (isset($_SESSION['id']) == $row2['id']) {
                        echo "<form class='delete-form' method='POST' action='".deleteComments($conn)."'>
                        <input type='hidden' name='cid' value = '".$row['cid']."' />    
                        <button type='submit' name='commentDelete'>Delete</button>
                    </form>
                    <form class='edit-form' method='POST' action='editcomment.php'>
                        <input type='hidden' name='cid' value = '".$row['cid']."' />
                        <input type='hidden' name='uid' value = '".$row['uid']."' />
                        <input type='hidden' name='date' value = '".$row['date']."' />
                        <input type='hidden' name='message' value = '".$row['message']."' />
                        <button>Edit</button>
                    </form>";
                    } else {
                         echo "<form class='edit-form' method='POST' action='".deleteComments($conn)."'>
                        <input type='hidden' name='cid' value = '".$row['cid']."' />    
                        <button type='submit' name='commentDelete'>Reply</button>
                    </form>";
                    }
                } else {
                    echo "<p class='commentmessge'>You need to be logged in to reply!</p>p>";
                }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template