public ActionResult UyeEkle(RegisterViewModel RegisterModel) { var ent = new EgitimMerkeziEntities(); Ogrenci _kursogrenci = new Ogrenci(); string aktivasyonkodu = Guid.NewGuid().ToString("N").Substring(0, 20).ToUpper(); _kursogrenci.Ad = RegisterModel.Ad; _kursogrenci.Soyad = RegisterModel.Soyad; _kursogrenci.Telefon = RegisterModel.Telefon; _kursogrenci.Eposta = RegisterModel.Email; _kursogrenci.Sifre = FormsAuthentication.HashPasswordForStoringInConfigFile(RegisterModel.Password, "md5"); _kursogrenci.Aktivasyon = aktivasyonkodu; _kursogrenci.Onay = false; _kursogrenci.Role = "Kullanici"; _kursogrenci.KayitTarihi = DateTime.Now; ent.Ogrenci.Add(_kursogrenci); ent.SaveChanges(); string mailIcerik = "EĞİTİM MERKEZİ AİLESİNE HOSGELDİNIZ<br>www.egitimmerkezi.com a kayıt olduğunuz için teşekkür ederiz. <br> Üyeliğinizi onaylamak için doğrulamak için aşağıdaki linke tıklayınız.<br> "; //mailIcerik += "<a href=\"http://egitimmerkezi.sakarya.edu.tr/Home/Aktivasyon?Eposta=" + RegisterModel.Email + "&AktivasyonKodu=" + aktivasyonkodu + "\" style=\"text-decoration:underline; color:#3ba5d8;\">Üyeliğimi Aktifleştir</a>"; mailIcerik += "<a href=\"http://egitimmerkezi.sakarya.edu.tr/Home/Aktivasyon?Eposta=" + RegisterModel.Email + "&AktivasyonKodu=" + aktivasyonkodu + "\" style=\"text-decoration:underline; color:#3ba5d8;\">Üyeliğimi Aktifleştir</a>"; MailGonder(RegisterModel.Email, "Eğitim Merkezi ~ Üyelik Aktivasyon", mailIcerik); return View("RegisterMessage"); }
public ActionResult UyeGiris(RegisterViewModel LoginModel) { if (ModelState.IsValid) { var ent = new EgitimMerkeziEntities(); string sifre = FormsAuthentication.HashPasswordForStoringInConfigFile(LoginModel.Password, "md5"); var uye = ent.Ogrenci.Where(x => x.Eposta == LoginModel.Email && x.Sifre == sifre && x.Onay == true).FirstOrDefault(); if (uye != null) { Session["eposta"] = LoginModel.Email; Session["role"] = uye.Role; return RedirectToAction("Index", "Home"); } else { TempData["Mesaj"] = "Kullanıcı Adı veya şifre yanlış, eposta aktivasyon maili onaylanmamıştır"; } } return View("Login"); }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return RedirectToAction("Index", "Home"); } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }