public string Auth(string username, string password)
 {
     Auth auth = new Auth();
     UserProfileSessionData u = auth.Login(username, password);
     if (u != null)
     {
         Session[Configuration.SESSION_ROLE] = u.role_code;
         Session[Configuration.SESSION_USER_ID] = u.user_id;
         Session[Configuration.SESSION_USER_FULLNAME] = u.fullname;
         Session[Configuration.SESSION_USER_USERNAME] = u.username;
         Session[Configuration.SESSION_USER_SCHOOL_ID] = u.school_id;
         Session[Configuration.SESSION_USER_SCHOOL_CODE] = u.school_code;
         Session[Configuration.SESSION_USER_SCHOOL_NAME] = u.school_name != null ? u.school_name : "Dummy Name";
         Session[Configuration.SESSION_SESSION_ACTIVE] = u.session_is_active;
         Session[Configuration.SESSION_SESSION_ID] = u.session_id;
         FormsAuthentication.SetAuthCookie(Session[Configuration.SESSION_USER_USERNAME].ToString(), true);
         return (true).ToJSON();
     }
     return (false).ToJSON();
 }
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            bool authorize = false;

            if(httpContext.Session[Configuration.SESSION_USER_ID] == null)
            {
                FormsAuthentication.SignOut();
            }

            var name = HttpContext.Current.User.Identity.Name;
            Role _dbRole = new Auth().GetRole(name);

            if (_dbRole == null)
                return false;

            foreach (var role in allowedroles)
            {
                if (_dbRole.role_code.ToString() == role.ToString())
                {
                    authorize = true; /* return true if Entity has current user(active) with specific role */
                }
            }
            return authorize;
        }
 public static bool Validate(UserProfileSessionData up)
 {
     Auth ls = new Auth();
     return false;
 }
 public ActionResult Viewprofile()
 {
     IEnumerable<Users_detail> _user_details =new Auth().GetUserDetails(HttpContext.User.Identity.Name);
     if (_user_details.FirstOrDefault().image == null) {
         _user_details.FirstOrDefault().image = "~/UserData/dummy.jpg";
     }
     return View(_user_details);
 }
 public ActionResult UpdateProfile()
 {
     Users_detail _user_details = new Auth().GetUserDetails(HttpContext.User.Identity.Name).FirstOrDefault() ;
     return View(_user_details);
 }