//called from Login view and authenticate user create session and if user not verified redirect to verifyemail view througn ajax promise

        public ActionResult LoginAuth(LoginCredentials lc)
        {
            using (JamiaRDBEntities db = new JamiaRDBEntities())
            {
                var user = db.tbl_user.SingleOrDefault(x => (x.userName == lc.userName) && (x.userPassword == lc.userPassword));
                if (user == null)
                {
                    user = db.tbl_user.SingleOrDefault(x => (x.userCellNumber == lc.userName) && (x.userPassword == lc.userPassword));
                }


                if (user == null)
                {
                    user = db.tbl_user.SingleOrDefault(x => (x.userDisplayName == lc.userName) && (x.userPassword == lc.userPassword));
                }

                if (user != null)
                {
                    if (lc.is_remember == true)
                    {
                        if (user.userToken == null)
                        {
                            var token = Guid.NewGuid().ToString();
                            user.userToken = token;
                            db.SaveChanges();
                        }

                        RememberChecked(user.userDisplayName, user.userToken);
                    }


                    Session["UserID"]   = user.userID;
                    Session["UserName"] = user.userDisplayName;
                    Session["UserRole"] = user.userRole;
                    return(Json("success"));
                }
                return(Json("failed"));
            }
        }
 public BatchController()
 {
     this.db = new JamiaRDBEntities();
 }
Example #3
0
 public CampusController()
 {
     this.db = new JamiaRDBEntities();
 }
Example #4
0
 public CourseController()
 {
     this.db = new JamiaRDBEntities();
 }
Example #5
0
      // GET: Files

      public FilesController()
      {
          this.db = new JamiaRDBEntities();
      }
Example #6
0
 public UserController()
 {
     db = new JamiaRDBEntities();
 }
 public StudentController()
 {
     this.db = new JamiaRDBEntities();
 }