public async Task <ActionResult> Giris(GirisViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var sonuc = await OturumAcmaYoneticisi.PasswordSignInAsync(model.Eposta, model.Sifre, model.HatirlaBeni, kilitlenmeliMi : false); switch (sonuc) { case SignInStatus.Success: return(LocaleYonlendir(returnUrl)); case SignInStatus.LockedOut: return(View("Kilitleme")); case SignInStatus.RequiresVerification: return(RedirectToAction("KoduGonder", new { ReturnUrl = returnUrl, RememberMe = model.HatirlaBeni })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Gecersiz Giris"); return(View(model)); } }
public ActionResult GirisYap(GirisViewModel model) { if (ModelState.IsValid) { Kullanici login = model.GirisKontrol(); if (login != null) { Session["kullanici"] = login; switch (login.RolID) { case 1: return(RedirectToAction("Index", "Admin")); case 2: return(RedirectToAction("Index", "OgretimGorevlisi")); case 3: return(RedirectToAction("Index", "Ogrenci")); } } ViewBag.Mesaj = "<div class='alert alert-danger display'><button class='close' data-close='alert'></button><span> Böyle bir kullanıcı yoktur... </span></div>"; } return(View(model)); }
public ActionResult Index(GirisViewModel model) { if (ModelState.IsValid) { if (model.Pass == _ayarlarYonetimi.Get(a => a.Anahtar == "AdminPass").Deger) { Session["UserName"] = "******"; return(RedirectToAction("Index", "UI")); } } this.ErrorMessage("Şifre yanlış!"); return(RedirectToAction("Index")); }
public ActionResult Giris(GirisViewModel vm, string donusUrl) { if (ModelState.IsValid) { //kullanıcı adı ve parolayı kontrol et var kullanici = db.Kullanicilar.SingleOrDefault(x => x.KullaniciAd == vm.Email); if (kullanici == null) { ModelState.AddModelError("", "Kullanıcı adı ya da parola yanlış!"); } if (ModelState.IsValid) { if (kullanici.ParolaHash == Security.HashPassword(vm.Parola)) { // https://stackoverflow.com/questions/31584506/how-to-implement-custom-authentication-in-asp-net-mvc-5 // todo: cookie authentication yap var ident = new ClaimsIdentity( new[] { // adding following 2 claim just for supporting default antiforgery provider new Claim(ClaimTypes.NameIdentifier, kullanici.Id.ToString()), new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string"), new Claim(ClaimTypes.Name, kullanici.KullaniciAd), // optionally you could add roles if any new Claim(ClaimTypes.Role, "Guest"), }, DefaultAuthenticationTypes.ApplicationCookie); HttpContext.GetOwinContext().Authentication.SignIn( new AuthenticationProperties { IsPersistent = true }, ident); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Kullanıcı adı ya da parola yanlış!"); } } } return(View()); }
public IActionResult Index(GirisViewModel k) { try { if (ModelState.IsValid) { var kullanici = _kullaniciService.KullaniciGetir(k.kullanici.KullaniciGiris.ToLower().Trim(), k.kullanici.KullaniciSifre); if (kullanici != null) { HttpContext.Session.SetObject("KullanıcıObjesi", kullanici); return(RedirectToAction("Index", "Anasayfa")); } else { var hataliGiris = new GirisViewModel() { kullanici = null, hatali = true }; return(View(hataliGiris)); } } else { var hataliGiris = new GirisViewModel() { kullanici = null, hatali = true }; return(View(hataliGiris)); } } catch (Exception) { var hataliGiris = new GirisViewModel() { kullanici = null, hatali = true }; return(View(hataliGiris)); } }
// GET: Admin/Giris public ActionResult Index(string pass) { if (Request.IsAuthenticated) { return(RedirectToAction("Index", "UI")); } else { if (!String.IsNullOrEmpty(pass)) { GirisViewModel model = new GirisViewModel() { Pass = pass }; return(View(model)); } } return(View()); }
public IActionResult Giris(GirisViewModel model) { RemoteService <Doktor> service = new RemoteService <Doktor>(); ServiceResponse <Doktor> response = service.Post(model, "Doktor", "doktorLogin"); if (response.isSuccessful) { //TODO Kullaniciyi sessionda tut HttpContext.Session.SetString("LoginType", "Doktor"); HttpContext.Session.SetObjectAsJson("Doktor", response.entity); return(RedirectToAction("index")); } if (response.Errors != null) { foreach (var item in response.Errors) { ModelState.AddModelError("Model", item); } } return(View(model)); }
public async Task <IActionResult> OturumAc(GirisViewModel girisViewModel) { if (!ModelState.IsValid) { return(View("GirisYap")); } var kullanici = UnitOfWork.ApplicationUserDal.GetQueryable().FirstOrDefault(p => p.Email == girisViewModel.Email && p.Password == girisViewModel.Password); if (kullanici != null) { kullanici.ApplicationType = UnitOfWork.ApplicationTypeDal.GetById(kullanici.ApplicationTypeId); var userClaims = new List <Claim>() { new Claim("Id", kullanici.Id.ToString()), new Claim("Name", kullanici.FirstName), new Claim("Surname", kullanici.LastName), new Claim("Email", kullanici.Email), new Claim("KullaniciTip", kullanici.ApplicationType.Type.ToString()), new Claim(ClaimTypes.Role, kullanici.ApplicationType.Type.ToString()), }; var grandmaIdentity = new ClaimsIdentity(userClaims, "Login"); var userPrincipal = new ClaimsPrincipal(new[] { grandmaIdentity }); await HttpContext.SignInAsync(userPrincipal); if (kullanici.ApplicationType.Type == "Admin") { return(RedirectToAction("Index", "People")); } else { return(RedirectToAction("Index", "Anasayfa")); } } else { return(View("GirisYap")); } }