Beispiel #1
0
 /// <summary>
 /// 如果有设置角色类型,则进行验证
 /// </summary>
 /// <param name="actionContext"></param>
 /// <returns></returns>
 protected override bool IsAuthorized(HttpActionContext actionContext)
 {
     if (HttpContext.Current.User.Identity.IsAuthenticated)
     {
         if (string.IsNullOrEmpty(this.Roles))
         {
             List <SysRoles> roles = SysRoles.getRolesList(RoleType);
             foreach (SysRoles role in roles)
             {
                 if (HttpContext.Current.User.IsInRole(role.role))
                 {
                     return(true);
                 }
             }
         }
     }
     return(base.IsAuthorized(actionContext));
 }
Beispiel #2
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="loginname"></param>
        protected virtual void getInfo(string loginname)
        {
            using (var db = new SysModelContainer())
            {
                var d = db.Db_SysUserSet.Single(p => p.loginName == loginname);
                setUserInfo(d);
                //获取角色
                this.roleInfo = SysRoles.sysRoles.Single(p => p.role.Equals(d.role));

                SysRoles userrole = SysRoles.sysRoles.Single(p => p.role.Equals(this.role));
                string   showName = string.Empty;
                if (userrole.cat == 0)
                {
                    //后台

                    showName = db.Db_SysUserSet.OfType <Db_ManagerUser>().Single(p => p.loginName == this.loginName).fullName;
                }
                else
                {
                    //其他,会员
                }
                this.showName = string.Format("{0}[{1},{2}]", showName, this.roleInfo.name, this.loginName);
            }
        }