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); } }
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); } } }
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); }