public ActionResult SignIn(BOL.Student student) { int count = studentManager.GetAllStudents().Where(x => x.Email == student.Email && x.IsApproved == "A").Count(); if (count == 0) { TempData["Msg"] = "Login failed"; return(RedirectToAction("Index")); } else { try { if (Membership.ValidateUser(student.Email, student.Password)) { FormsAuthentication.SetAuthCookie(student.Email, false); return(RedirectToAction("Dashboard", "Home", new { Area = "Common" })); } else { TempData["Msg"] = "Login failed"; return(RedirectToAction("Index")); } } catch (Exception e) { TempData["Msg"] = "Login failed " + e.Message; return(RedirectToAction("Index")); } } }
public ActionResult ChangePassword(BOL.Student student) { var students = studentManager.GetAllStudents().Where(x => x.Email == User.Identity.Name).FirstOrDefault(); if (student.Password == null) { TempData["Msgp"] = "This Value is Required"; return(RedirectToAction("Index")); } else if (student.NewPassword == null) { TempData["Msgn"] = "This Value is Required"; return(RedirectToAction("Index")); } else if (student.NewConfrimPassword == null) { TempData["Msgc"] = "This Value is Required"; return(RedirectToAction("Index")); } else { if (student.NewPassword == student.NewConfrimPassword) { if (Crypto.VerifyHashedPassword(students.Password, student.Password)) { students.Password = Crypto.HashPassword(student.NewPassword); students.NewPassword = Crypto.HashPassword(student.NewPassword); students.ConfrimPassword = Crypto.HashPassword(student.NewPassword); studentManager.Update(students); TempData["Msg"] = "Password Successfully Changed"; return(RedirectToAction("Index")); } else { TempData["Msg"] = "Password Changed unsuccessfull"; return(RedirectToAction("Index")); } } else { TempData["Msg1"] = "New Password & new Confirm password didn't mached"; return(RedirectToAction("Index")); } } }