Ejemplo n.º 1
0
 public override bool ValidateUser(string username, string password)
 {
     oCCUSER = oDBContext.CCUSERs.FirstOrDefault(t => t.USERID == username && t.USERPASSWORD == password);
     if (oCCUSER != null)
     {
         FormsAuthentication.SetAuthCookie(username, false);
         Roles.AddUserToRole(oCCUSER.USERID, oCCUSER.CCROLE.ROLENAME);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
 public override bool IsUserInRole(string username, string roleName)
 {
     using (OBLCONTACTCENTEREntities db = new OBLCONTACTCENTEREntities())
     {
         CCUSER user = db.CCUSERs.FirstOrDefault(u => u.USERID == username && u.CCROLE.ROLENAME == roleName);
         if (user != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 3
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var allowedRoles = Roles;
            var currentUser  = httpContext.User.Identity;

            using (OBLCONTACTCENTEREntities db = new OBLCONTACTCENTEREntities())
            {
                CCUSER user = db.CCUSERs.FirstOrDefault(u => currentUser.IsAuthenticated && u.USERID == currentUser.Name && u.CCROLE.ROLENAME.Contains(allowedRoles));
                if (user != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            //return base.AuthorizeCore(httpContext);
        }