Exemplo n.º 1
0
 public override string[] GetRolesForUser(string UserId)
 {
     using (OFFERDBEntities oEntity = new OFFERDBEntities())
     {
         var      enumType = Convert.ToInt32(Enumaretion.DBEnumType.SysUserType);
         string[] ret      = oEntity.SysUsers.Where(t => t.UserId == UserId).Select(x => x.SysEnum.EnumName.ToLower()).ToArray();
         return(ret);
     }
 }
Exemplo n.º 2
0
 public override bool IsUserInRole(string username, string roleName)
 {
     using (OFFERDBEntities db = new OFFERDBEntities())
     {
         SysUser user = db.SysUsers.FirstOrDefault(u => u.UserId == username && u.SysEnum.EnumName.ToLower().Contains(roleName.ToLower()));
         if (user != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 3
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var allowedRoles = Roles;
            var currentUser  = httpContext.User.Identity;

            using (OFFERDBEntities db = new OFFERDBEntities())
            {
                SysUser user = db.SysUsers.FirstOrDefault(u => u.UserId == currentUser.Name && u.SysEnum.EnumName.ToLower().Contains(allowedRoles));
                if (user != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            //return base.AuthorizeCore(httpContext);
        }