JSON结构 - 授权用户菜单

时间:2017-04-07 12:22:58

标签: json database authentication authorization

我想通过用户登录显示菜单。 etc:如果我用user1登录,只需显示menu1,menu2,menu3。如果我使用user2登录,只需显示menu2和menu3。

我已经为每个模块创建了JSON结构。

        <td class="d-flex flex-wrap">
            <input class="form-control w-50 flex-first" placeholder="First name" type="text" formcontrolname="firstName">
            <div *ngif="customerForm.controls.firstName.touched" class="w-50">
                <div class="form-error" *ngif="customerForm.controls.firstName.hasError('required')">
                    first name is required.
                </div>
            </div>
            <input class="form-control w-50 flex-first" placeholder="Last name" type="text" formcontrolname="lastName">
            <div *ngif="customerForm.controls.lastName.touched"  class="w-50 flex-last">
                <div class="form-error" *ngif="customerForm.controls.lastName.hasError('required')">
                    last name is required.
                </div>
            </div>
        </td>

因此,每个模块都有一个菜单,并且都有3个模块。如何为用户授权编辑这个json结构?我把用户的对象放到这个JSON模型?

谢谢大家。

1 个答案:

答案 0 :(得分:0)

这个问题对我来说并不是很清楚,但是如果你想将它合并到同一个JSON中,那么你可以将&#34; userlist&#34;作为数组属性。像这样的事情(我从模块1中取样):

{ "header":"Data Peserta", "subheader":"Kepesertaan", "icon":"sap-icon://log", "route":"datapeserta", "userlist":["user1","user2","user3"] }, { "header":"Header1", "subheader":"Kepesertaan", "icon":"sap-icon://delete", "route":"first", "userlist":["user2","user3"] }

这将为您提供更精细的控制访问。在这种情况下,在模块中哪个用户可以显示哪个Header / Subheader等。