[英]Role Based UI in Angular 2
您需要推出自己的mvc5服務器端解決方案,您可能會在Internet上找到許多示例,使用類似以下的擴展方法,您可以通過razor / c#檢查權限,並且它將基於html輸出帶有正確角度標記的html用戶/角色。
public static bool UserHasPermission(this ControllerBase controller, string permissionString)
{
bool permissionFound = false;
try
{
permissionFound = new RoleUserCheck(controller.ControllerContext.HttpContext.User.Identity.Name).UserHasPermission(permissionString);
}
catch { }
return permissionFound;
}
那么您可以在局部/視圖上通過剃刀標記訪問該功能。
@{
if (ViewContext.Controller.UserHasPermission("DeleteWithPaymentRollback"))
{
<button type="button" (click)="showconfirm()" class="btn btn-danger btn-xs">
<span class="fa fa-recycle"></span>
</button>
}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.