public ActionResult Login(string email, string password) { if (email != null && password != null) { using (LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities()) { var account = db.Employees.Where(x => x.email.Equals(email)).SingleOrDefault(); if (account != null) { var passwordCheck = account.password.Equals(EncryptPassword.EncryptForPassword(password)); if (passwordCheck) { Session["username_Employee"] = account.fullname; Session["email_Employee"] = account.email; Session["password_Employee"] = EncryptPassword.DecryptPassword(account.password); Session["id_Employee"] = account.id; Session["image_Employee"] = account.avatar; FormsAuthentication.SetAuthCookie(email, false); return(RedirectToAction("Index", "DashBoard")); } else { return(new RedirectResult(url: "/Admin/Account/Login?message=invalid_password")); } } else { return(new RedirectResult(url: "/Admin/Account/Login?message=invalid_email")); } } } return(RedirectToAction("Index", "DashBoard")); }
public ActionResult forgotPassword(FormCollection form) { LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities(); string email = Request.Form["email"]; Employee employee = db.Employees.Where(x => x.email.Equals(email)).FirstOrDefault(); if (employee == null) { return(new RedirectResult(url: "/Admin/Account/forgotPassword?message=invalid_email")); } else { string password = EncryptPassword.DecryptPassword(employee.password); SendEmail.SendMail("Gửi từ Laundry Store, Xác nhận người dùng ! ", employee.email, " lấy lại mật khẩu !" + " Với tên đăng nhập : " + employee.email + " Mật khẩu của bạn là: " + password + ", click đường dẫn dưới đây để quay về trang đăng nhập " + "https://localhost:44335/Admin/Account/Login"); return(new RedirectResult(url: "/Admin/Account/Login?message=confirm_email")); } }
public ActionResult Login(string email, string password) { if (email != null && password != null) { using (LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities()) { var account = db.Customers.Where(x => x.email.Equals(email) && x.status == true && x.activated == true).FirstOrDefault(); if (account != null) { if (account.activated == true) { var passwordCheck = account.password.Equals(EncryptPassword.EncryptForPassword(password)); if (passwordCheck) { Session["username_Customer"] = account.fullname; Session["email_Customer"] = account.email; Session["password_Customer"] = EncryptPassword.DecryptPassword(account.password); Session["id_Customer"] = account.id; Session["image_Customer"] = account.avatar; FormsAuthentication.SetAuthCookie(email, false); return(RedirectToAction("Index", "Home")); } else { return(new RedirectResult(url: "/Account/Login?message=invalid_password")); } } else { return(new RedirectResult(url: "/Account/Login?message=authentication_email")); } } else { return(new RedirectResult(url: "/Account/Login?message=invalid_email")); } } } return(View()); }
public ActionResult CreateMessage(FormCollection form) { string name = Request.Form["name"]; string email = Request.Form["email"]; string message = Request.Form["message"]; string idPost = Request.Form["idPost"]; string passwordDefault = "laundry1234"; //khach hang khong dang nhap. tao tai khoan cho khach hang nhu email va ten ma khach hang nhap vao Customer customer = new Customer(); if (Session["id_Customer"] == null) { var account = db.Customers.Where(x => x.email.Equals(email)).FirstOrDefault(); if (account != null) { return(new RedirectResult(url: "/Blogs/Details/" + idPost + "?message=invalid_email")); } customer.email = email; customer.password = EncryptPassword.EncryptForPassword(passwordDefault); customer.fullname = name; customer.address = ""; customer.idCounty = 1; customer.avatar = "Assets/Client/resources/image/" + "customerDefault.jpg"; customer.activated = true; customer.status = true; customer.createdDate = DateTime.Now; customer.modifyDate = DateTime.Now; customer.modifyBy = name; customer.dayOfBirth = DateTime.Now; customer.roleId = 3; db.Customers.Add(customer); db.SaveChanges(); string password = EncryptPassword.DecryptPassword(customer.password); SendEmail.SendMail("Gửi từ Laundry Store, Xác nhận người dùng ! ", customer.email, " Bạn vừa đăng kí thành công tài khoản tại Laundry Store !" + " Với tên đăng nhập : " + customer.email + " Bạn có thể sử dụng email trên để đăng nhập vào cửa hàng của chúng tôi với mật khẩu mặc định là : " + password + " " + " Vui lòng truy cập vào đường dẫn dưới đây để cập nhật thông tin tài khoản " + "https://localhost:44335/Account/infoProfile/" + customer.id); } //khach hang co dang nhap tai khoan else { var customerId = int.Parse(Session["id_Customer"].ToString()); customer = db.Customers.Find(customerId); if (customer != null) { customer.email = Session["email_Customer"].ToString(); customer.fullname = Session["username_Customer"].ToString(); customer.modifyDate = DateTime.Now; customer.modifyBy = Session["username_Customer"].ToString(); db.SaveChanges(); } } Comment comment = new Comment(); comment.content = message; comment.customerId = customer.id; comment.newId = Convert.ToInt32(idPost); comment.createdDate = DateTime.Now; comment.createdBy = customer.fullname; comment.modifyDate = DateTime.Now; comment.modifyBy = customer.fullname; comment.status = true; db.Comments.Add(comment); db.SaveChanges(); return(new RedirectResult(url: "/Blogs/Details/" + idPost + "?message=comment")); }