/// <summary>
        ///
        /// </summary>
        /// <param name="roleGroups"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool UserInRoleGroups(this RoleGroupsAttribute roleGroups, IUser user)
        {
            bool result = false;

            if (roleGroups != null && user != null)
            {
                result = RolesDefineConfig.GetConfig().IsCurrentUserInRoles(user, roleGroups.Parse().ToArray());
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// 当前用户是否在指定的角色中
        /// </summary>
        /// <returns></returns>
        public bool IsCurrentUserInRoles()
        {
            bool result = false;

            if (RolesDefineName.IsNotEmpty())
            {
                result = RolesDefineConfig.GetConfig().IsCurrentUserInRoles(this.RolesDefineName);
            }

            if (result == false && this.Roles.IsNotEmpty())
            {
                result = HttpContext.Current.User.IsInRole(this.Roles);
            }

            return(result);
        }