public ActionResult CheckLogin() { var user = Request["user"]; var pass = Request["pass"]; TeacherModel model = new TeacherModel(); TeacherEntity teacher = model.getTeacher(user, pass); if (teacher != null) { Session["teacher"] = teacher; Session.Timeout = 60 * 5; return Redirect("Index"); } return Redirect("Login"); }
public ActionResult ModifyProfile() { if (loginStatus() == false) { return Redirect("Login"); } var response = new Dictionary<string, string>(); var username = Request.Params["username"]; var oldpass = Request.Params["oldpass"]; var newpass = Request.Params["newpass"]; if (username == null || oldpass == null || newpass == null) { response.Add("status", "failed"); response.Add("error", "bad param"); } var model = new TeacherModel(); TeacherEntity OldTeacher = (TeacherEntity)Session["teacher"]; var teacher = model.getTeacher(OldTeacher.username, oldpass); if (teacher == null) { response.Add("status", "failed"); response.Add("error", "wrong oldpass"); return Json(response); } int row = model.ChangePass(OldTeacher.username, username, newpass); if (row != 1) { response.Add("status", "failed"); response.Add("error", "update error"); return Json(response); } if (OldTeacher.username != username) { Logout(); } response.Add("status", "success"); return Json(response); }