public JsonResult LostPassword(string lost_email) { ModalLoginJsonResult result = new ModalLoginJsonResult(); lost_email = lost_email?.Trim(); if (string.IsNullOrEmpty(lost_email)) { result.HasError = true; result.Message = "E-posta adresi bos gecilemez."; } else { // TODO : LostPassword => Check e-posta into database. // Entity Framework or ADO.NET code here.. SiteUser user = db.SiteUsers.FirstOrDefault(x => x.Email == lost_email); if (user != null) { // TODO : Send Password with EMail to user // user.Password bilgisi mail ile kullanıcıya(user.Email) gönderilir. result.HasError = false; result.Message = "Sifreniz gonderilmistir."; } else { result.HasError = true; result.Message = "E-Posta adresi bulunamamistir."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult LostPassword(string lost_email) { ModalLoginJsonResult result = new ModalLoginJsonResult(); lost_email = lost_email?.Trim(); if (string.IsNullOrEmpty(lost_email)) { result.HasError = true; result.Message = "E-posta adresi boş geçilemez."; } else { // TODO : LostPassword => Check e-posta into database. // Entity Framework or ADO.NET code here.. if (lost_email == "*****@*****.**") // for example.. { result.HasError = false; result.Message = "Şifreniz gönderilmiştir."; } else { result.HasError = true; result.Message = "E-Posta adresi bulunamamıştır."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SignUp(string register_username, string register_email, string register_password) { ModalLoginJsonResult result = new ModalLoginJsonResult(); register_username = register_username?.Trim(); register_email = register_email?.Trim(); register_password = register_password?.Trim(); if (string.IsNullOrEmpty(register_username) || string.IsNullOrEmpty(register_email) || string.IsNullOrEmpty(register_password)) { result.HasError = true; result.Result = "Lütfen tüm alanları doldurunuz."; } else { LoginUser user = db.Uyeler.FirstOrDefault(x => x.Username == register_username || x.Email == register_email); if (user != null) { result.HasError = true; result.Result = "Kullanıcı adı ya da e-posta kullanılıyor."; } else { user = db.Uyeler.Add(new LoginUser() { Name = string.Empty, Surname = string.Empty, Email = register_email, Username = register_username, Password = register_password, RoleName = "member", ProfileImageFileName = "user_boy.png" }); if (db.SaveChanges() > 0) { result.HasError = false; result.Result = "Hesap oluşturuldu."; // Detached : This should be used for example if you want to load entity only to read data and you don't plan to modify them. db.Entry(user).State = System.Data.Entity.EntityState.Detached; user.Password = string.Empty; // Session is not include pass for security. // Set login to session for auto login from register. Session["login"] = user; } else { result.HasError = true; result.Result = "Hata oluştu."; } } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SignUp(string register_username, string register_email, string register_password) { ModalLoginJsonResult result = new ModalLoginJsonResult(); register_username = register_username?.Trim(); register_email = register_email?.Trim(); register_password = register_password?.Trim(); if (string.IsNullOrEmpty(register_username) || string.IsNullOrEmpty(register_email) || string.IsNullOrEmpty(register_password)) { result.HasError = true; result.Result = "Please, fill all blank fields."; } else { LoginUser user = db.LoginUsers.FirstOrDefault(x => x.Username == register_username || x.Email == register_email); if (user != null) { result.HasError = true; result.Result = "Username or e-mail address to be used."; } else { user = db.LoginUsers.Add(new LoginUser() { Name = string.Empty, Surname = string.Empty, Email = register_email, Username = register_username, Password = register_password }); if (db.SaveChanges() > 0) { result.HasError = false; result.Result = "Account created."; // Detached : This should be used for example if you want to load entity only to read data and you don't plan to modify them. db.Entry(user).State = System.Data.Entity.EntityState.Detached; user.Password = string.Empty; // Session is not include pass for security. // Set login to session for auto login from register. Session["login"] = user; } else { result.HasError = true; result.Result = "Error occured."; } } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SignUp(string register_username, string register_email, string register_password) { ModalLoginJsonResult result = new ModalLoginJsonResult(); register_username = register_username?.Trim(); register_email = register_email?.Trim(); register_password = register_password?.Trim(); if (string.IsNullOrEmpty(register_username) || string.IsNullOrEmpty(register_email) || string.IsNullOrEmpty(register_password)) { result.HasError = true; result.Message = "Lutfen tum alanlar doldurulmalidir."; } else { // TODO : SignUp => Insert account info to database. // Entity Framework or ADO.NET code here.. SiteUser user = new SiteUser() { Name = string.Empty, Surname = string.Empty, Email = register_email, Username = register_username, Password = register_password }; db.SiteUsers.Add(user); if (db.SaveChanges() > 0) { result.HasError = false; result.Message = "Hesap olusturulmustur."; // Set login to session for auto login from register form. Session["login"] = user; } else { result.HasError = true; result.Message = "Hata olustu."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SignUp(string register_username, string register_email, string register_password) { ModalLoginJsonResult result = new ModalLoginJsonResult(); register_username = register_username?.Trim(); register_email = register_email?.Trim(); register_password = register_password?.Trim(); if (string.IsNullOrEmpty(register_username) || string.IsNullOrEmpty(register_email) || string.IsNullOrEmpty(register_password)) { result.HasError = true; result.Message = "Lütfen tüm alanlar doldurulmalıdır."; } else { // TODO : SignUp => Insert account info to database. // Entity Framework or ADO.NET code here.. if (register_username == "muratbaseren") // for example.. { result.HasError = false; result.Message = "Hesap oluşturulmuştur."; // Set login to session for auto login from register. Session["login"] = new SysUser() { Id = 1, Name = "K. Murat", Surname = "Başeren", Username = "******", Email = "*****@*****.**" }; } else { result.HasError = true; result.Message = "Hata oluştu."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SignIn(string login_username, string login_password, bool login_rememberme) { ModalLoginJsonResult result = new ModalLoginJsonResult(); login_username = login_username?.Trim(); login_password = login_password?.Trim(); if (string.IsNullOrEmpty(login_username) || string.IsNullOrEmpty(login_password)) { result.HasError = true; result.Message = "Kullanıcı adı ya da şifre boş geçilemez."; } else { // TODO : SignIn => Check account info into database. // Entity Framework or ADO.NET code here.. if (login_username == "murat" && login_password == "baseren") // for example.. { result.HasError = false; result.Message = "Giriş başarılı."; // Set login to session Session["login"] = new SysUser() { Id = 1, Name = "K. Murat", Surname = "Başeren", Username = "******", Email = "*****@*****.**" }; } else { result.HasError = true; result.Message = "Kullanıcı adı ya da şifre başarısız."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SignIn(string login_username, string login_password, bool login_rememberme) { ModalLoginJsonResult result = new ModalLoginJsonResult(); login_username = login_username?.Trim(); login_password = login_password?.Trim(); if (string.IsNullOrEmpty(login_username) || string.IsNullOrEmpty(login_password)) { result.HasError = true; result.Result = "Username and password can not be empty."; } else { // AsNoTracking : This should be used for example if you want to load entity only to read data and you don't plan to modify them. LoginUser user = db.LoginUsers.AsNoTracking().FirstOrDefault(x => x.Username == login_username && x.Password == login_password); if (user != null) { result.HasError = false; result.Result = "Login successfully."; user.Password = string.Empty; // Session is not include pass for security. // Set login to session Session["login"] = user; } else { result.HasError = true; result.Result = "Username or password is wrong."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SignIn(string login_username, string login_password, bool login_rememberme) { ModalLoginJsonResult result = new ModalLoginJsonResult(); login_username = login_username?.Trim(); login_password = login_password?.Trim(); if (string.IsNullOrEmpty(login_username) || string.IsNullOrEmpty(login_password)) { result.HasError = true; result.Message = "Kullanıcı adı ya da şifre boş geçilemez."; } else { // TODO : SignIn => Check account info into database. // Entity Framework or ADO.NET code here.. SiteUser user = db.SiteUsers.FirstOrDefault( x => x.Username == login_username && x.Password == login_password); if (user != null) { result.HasError = false; result.Message = "Giriş başarılı"; // Set login to session Session["login"] = user; } else { result.HasError = true; result.Message = "Kullanıcı adı ya da şifre yanlış."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult LostPassword(string lost_email) { ModalLoginJsonResult result = new ModalLoginJsonResult(); lost_email = lost_email?.Trim(); if (string.IsNullOrEmpty(lost_email)) { result.HasError = true; result.Result = "E-Mail address can not be empty."; } else { // TODO : KMB Modal Login - Lost Password LoginUser user = db.LoginUsers.FirstOrDefault(x => x.Email == lost_email); if (user != null) { // // TODO : Send password with e-mail. // Reads mail settings from AppSettings into web.config file. // #region Sends password to user mail address. // Sends password to user mail address. //bool sent = mailer.SendMail($"<b>Your password :</b> {user.Password}", //user.Email, "Your missed password", true); //if (sent == false) //{ // result.HasError = true; // result.Result = "Password has not been sent."; //} //else //{ // result.HasError = false; // result.Result = "Password has been sent."; //} #endregion #region Sends password reset link to user mail address. // Sends password reset link to user mail address. user.LostPasswordToken = Guid.NewGuid(); if (db.SaveChanges() > 0) { bool sent = mailer.SendMail( $"<b>Your reset password link :</b> <a href='http://{Request.Url.Authority}/ModalLogin/ResetPassword/{user.LostPasswordToken}' target='_blank'>Reset Password</a>", user.Email, "Reset Password", true); if (sent == false) { result.HasError = true; result.Result = "Reset Password link has not been sent."; } else { result.HasError = false; result.Result = "Reset Password link has been sent."; } } else { result.HasError = true; result.Result = "Error occured."; } #endregion } else { result.HasError = true; result.Result = "E-Mail address not found."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult LostPassword(string lost_email) { ModalLoginJsonResult result = new ModalLoginJsonResult(); lost_email = lost_email?.Trim(); if (string.IsNullOrEmpty(lost_email)) { result.HasError = true; result.Result = "E-posta adresi boş geçilemez."; } else { // TODO : KMB Modal Login - Lost Password LoginUser user = db.Uyeler.FirstOrDefault(x => x.Email == lost_email); if (user != null) { // // TODO : Send password with e-mail. // Reads mail settings from AppSettings into web.config file. // #region Sends password to user mail address. // Sends password to user mail address. //bool sent = mailer.SendMail($"<b>Your password :</b> {user.Password}", //user.Email, "Your missed password", true); //if (sent == false) //{ // result.HasError = true; // result.Result = "Password has not been sent."; //} //else //{ // result.HasError = false; // result.Result = "Password has been sent."; //} #endregion #region Sends password reset link to user mail address. // Sends password reset link to user mail address. user.LostPasswordToken = Guid.NewGuid(); if (db.SaveChanges() > 0) { bool sent = mailer.SendMail( $"<b>Şifre sıfırlama adresiniz :</b> <a href='http://{Request.Url.Authority}/ModalLogin/ResetPassword/{user.LostPasswordToken}' target='_blank'>Sıfırla</a>", user.Email, "Travelers - Şifre Sıfırlama", true); if (sent == false) { result.HasError = true; result.Result = "Şifre sıfırlama adresi tanımlanmamış."; } else { result.HasError = false; result.Result = "Şifre sıfırlama mesajı gönderildi.."; } } else { result.HasError = true; result.Result = "Hata oluştu."; } #endregion } else { result.HasError = true; result.Result = "E-posta adresi bulunamadı."; } } return(Json(result, JsonRequestBehavior.AllowGet)); }