public ActionResult ResetPassword(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (TeklifContext dc = new TeklifContext()) { var user = dc.Users.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault(); if (user != null) { user.Password = Crypto.Hash(model.NewPassword); user.ResetPasswordCode = ""; dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "Yeni şifre başarıyla güncellendi..."; } } } else { message = "Geçersiz şifre..."; } ViewBag.Message = message; return(View(model)); }
public ActionResult ForgotPassword(string EmailID) { //Verify Email ID //Generate Reset password link //Send Email string message = ""; bool status = false; using (TeklifContext dc = new TeklifContext()) { var account = dc.Users.Where(a => a.EmailID == EmailID).FirstOrDefault(); if (account != null) { //Send email for reset password string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(account.EmailID, resetCode, "ResetPassword"); account.ResetPasswordCode = resetCode; //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property //in our model class in part 1 dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "Şifre sıfırlama linki e-mail adresinize yollandı.."; } else { message = "Hesap bulunamadı !!"; } } ViewBag.Message = message; return(View()); }
public ActionResult Kontrol(FormCollection c) { if (Session["user"] is User kullanici) { Urunler u = new Urunler(); u.Aciklama = ((Urunler)Session["urun"]).Aciklama.ToString(); u.AltLimit = ((Urunler)Session["urun"]).AltLimit; u.Bakilma = 0; u.Baslik = ((Urunler)Session["urun"]).Baslik.ToString(); u.DurumId = ((Urunler)Session["urun"]).DurumId; u.KategoriId = ((Urunler)Session["urun"]).KategoriId; u.UrunOlusturma = DateTime.Now; u.UserID = kullanici.UserID; u.Yayın = true; var ur = urn.Create(u); var menu = Session["res"] as List <Resimler>; foreach (var item in menu) { Resimler rs = new Resimler(); rs.ImageUrl = item.ImageUrl; rs.Resim = item.Resim; rs.UrunId = u.UrunId; rsm.Create(rs); } string img = Session["anagorsel"].ToString(); int lst = db.Resimlers.Where(x => x.ImageUrl == img).Select(x => x.ResimId).Single(); AnaGorsel ana = new AnaGorsel(); ana.ResimId = lst; db.AnaGorsels.Add(ana); db.SaveChanges(); u.GorselId = ana.GorselId; TempData["msg"] = urn.Edit(u) ? "Ürününüz Yayında" : "Hata !! Lütfen Tekrar Deneyiniz..."; return(RedirectToAction("Index", "Kullanici")); } return(View()); }
public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User1 user) { bool Status = false; string message = ""; if (ModelState.IsValid) { #region //Email is already Exist var isExist = IsEmailExist(user.EmailID); if (isExist) { ModelState.AddModelError("EmailExist", "E-posta zaten var"); return(View(user)); } #endregion #region Generate Activation Code user.ActivationCode = Guid.NewGuid(); #endregion #region Password Hashing user.Password = Crypto.Hash(user.Password); user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword); // #endregion user.IsEmailVerified = false; #region Save to Database using (TeklifContext dc = new TeklifContext()) { user.UyelikBaslangic = DateTime.Now; dc.Users.Add(user); dc.SaveChanges(); Session["user"] = user; //Send Email to User SendVerificationLinkEmail(user.EmailID, user.ActivationCode.ToString()); message = "Kayıt işleminizi yarıladınız :) Hesap etkinleştirme " + " bağlantısı email adresinize gönderildi:" + user.EmailID; Status = true; } #endregion } else { message = "Geçersiz istek"; } // Model Validation ViewBag.Message = message; ViewBag.Status = Status; return(View(user)); }
public ActionResult VerifyAccount(string id) { bool Status = false; using (TeklifContext dc = new TeklifContext()) { dc.Configuration.ValidateOnSaveEnabled = false; // This line I have added here to avoid // Confirm password does not match issue on save changes var v = dc.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.IsEmailVerified = true; dc.SaveChanges(); Status = true; } else { ViewBag.Message = "Geçersiz istek"; } } ViewBag.Status = Status; return(View()); }