本文整理汇总了C#中Permissions.HasPermission方法的典型用法代码示例。如果您正苦于以下问题:C# Permissions.HasPermission方法的具体用法?C# Permissions.HasPermission怎么用?C# Permissions.HasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permissions
的用法示例。
在下文中一共展示了Permissions.HasPermission方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInit
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
#region Security check
currentLoggedInUserPermissions = PermissionService.Instance.GetCurrentLoggedInUserPermissions();
if ( currentLoggedInUserPermissions == null || !currentLoggedInUserPermissions.HasPermission( StoreSpecificPermissionType.AccessSettings, store.Id ) ) {
throw new SecurityException();
}
#endregion
AddTab( CommonTerms.Common, PnCommon, SaveButton_Clicked );
AddTab( StoreTerms.Order, PnOrder, SaveButton_Clicked );
AddTab( StoreTerms.Product, PnProduct, SaveButton_Clicked );
AddTab( CommonTerms.GiftCards, PnGiftCard, SaveButton_Clicked );
AddTab( "UI", PnTemplateRendering, SaveButton_Clicked );
PPnlName.Text = CommonTerms.Name;
PPnlDefaultCountry.Text = StoreTerms.DefaultCountry;
PPnlDefaultVatGroup.Text = StoreTerms.DefaultVatGroup;
PPnlDefaultOrderStatus.Text = StoreTerms.DefaultOrderStatus;
PPnlConfirmationEmail.Text = StoreTerms.ConfirmationEmailTemplate;
PPnlPaymentInconsistencyEmail.Text = StoreTerms.PaymentInconsistencyEmailTemplate;
PPnlPricesIsSpecifiedWithVat.Text = StoreTerms.PricesIsSpecifiedWithVat;
PPnlChkPersistOrderId.Text = StoreTerms.UseCookies;
PPnlChkOrderPersistanceTimeout.Text = StoreTerms.CookieTimeout + "<br /><small>" + StoreTerms.CookieTimeoutHelp + "</small>";
PPnlCartNumberPrefix.Text = StoreTerms.CartNumberPrefix;
PPnlOrderNumberPrefix.Text = StoreTerms.OrderNumberPrefix;
PPnlProductPropertyAliases.Text = StoreTerms.ProductPropertyAliases;
PPnlProductUniquenessPropertyAliases.Text = StoreTerms.ProductUniquenessPropertyAliases;
PPnlStockSharingStore.Text = StoreTerms.StockSharingStore + "<br /><small>" + StoreTerms.StockSharingStoreHelp + "</small>";
PPnlGiftCardLength.Text = StoreTerms.Length;
PPnlGiftCardDaysValid.Text = StoreTerms.DaysValid;
PPnlGiftCardPrefix.Text = StoreTerms.Prefix;
PPnlGiftCardSuffix.Text = StoreTerms.Suffix;
PPnlEditOrderUIFile.Text = StoreTerms.EditOrderUiFile;
PPnlTemplateRendering.Text = StoreTerms.AllowedTemplateFilesForRendering + "<br /><small>" + StoreTerms.AllowedTemplateFilesForRenderingHelp + "</small>";
}
示例2: OnInit
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
umbraco.BusinessLogic.User currentUser = umbraco.helper.GetCurrentUmbracoUser();
#region Security check
currentUserPermissions = PermissionService.Instance.GetCurrentLoggedInUserPermissions();
if ( currentUserPermissions == null || !currentUserPermissions.HasPermission( GeneralPermissionType.AccessSecurity ) ) {
throw new SecurityException();
} else {
bool showUser = true;
umbraco.BusinessLogic.User user = umbraco.BusinessLogic.User.GetUser( int.Parse( HttpContext.Current.Request.QueryString[ "id" ] ) );
showUser = !user.IsRoot(); //Don't ever show admin user
if ( showUser ) {
bool showAllUsers = currentUser.IsRoot() || currentUser.Applications.Any( a => a.alias == "users" );
showUser = showAllUsers || currentUser.Id == user.Id || ( permissions != null && currentUserPermissions.StoreSpecificPermissions.Any( p => p.Value.HasFlag( StoreSpecificPermissionType.AccessStore ) && permissions.HasPermission( StoreSpecificPermissionType.AccessStore, p.Key ) ) );
}
if ( !showUser ) {
throw new SecurityException();
}
}
#endregion
AddTab( CommonTerms.Common, PnlCommon, SaveButton_Clicked );
PPnlAccessSecurity.Text = StoreTerms.Security;
ImgAccessSecurity.ImageUrl = WebUtils.GetWebResourceUrl( Constants.TreeIcons.Lock );
PPnlAccessLicenses.Text = DeveloperTerms.Licenses;
ImgAccessLicenses.ImageUrl = WebUtils.GetWebResourceUrl( Constants.TreeIcons.LicenseKey );
PPnlCreateAndDeleteStore.Text = CommonTerms.CreateAndDeleteStore;
ImgCreateAndDeleteStore.ImageUrl = WebUtils.GetWebResourceUrl( Constants.TreeIcons.Store );
PnStoreSpecificPermissions.Text = CommonTerms.Stores;
PPnlStoreSpecificPermissions.Text = CommonTerms.StoreSpecificPermissions;
}