コード例 #1
0
        public ActionResult Login(UserCard userCard)
        {
            UserCard uye = _usRep.FirstOrDefault(x => x.UserName == userCard.UserName);

            string decrypted = DantexCrypt.DeCrypt(uye.Password);

            if (userCard.Password == decrypted && uye != null)
            {
                if (uye.Role == ENTITIES.Enums.UserCardRole.Admin)
                {
                    if (!uye.Active)
                    {
                        return(AktifKontrol());
                    }
                    Session["admin"] = uye;
                    return(RedirectToAction("CategoryList", "Category", new { area = "Admin" }));
                }


                else
                {
                    ViewBag.RolBelirsiz = "Rol belirlenmemiş";
                    return(View());
                }
            }

            ViewBag.KullaniciYok = "Kullanıcı bulunamadı";
            return(View());
        }
コード例 #2
0
        public ActionResult Login([Bind(Prefix = "AppUser")] AppUser item)
        {
            AppUser yakalanan = apRep.FirstOrDefault(x => x.UserName == item.UserName);
            string  decrypted = DantexCrypt.DeCrypt(yakalanan.Password);

            if (item.Password == decrypted && yakalanan != null && yakalanan.Role == ENTITIES.Enum.UserRole.Admin)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["admin"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category"));
            }
            else if (yakalanan.Role == ENTITIES.Enum.UserRole.Member)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["member"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category"));
            }
            ViewBag.KullaniciYok = "Kullanici Bulunamadi";
            return(View());
        }
コード例 #3
0
        public ActionResult Login(AppUser item)
        {
            #region EskiAlgoritma
            //if (arep.Any(x=>x.UserName == item.UserName && x.Password==item.Password && x.IsActive == true && x.Role == UserRole.Member))
            //{
            //    Session.Add("member",arep.Where(x => x.UserName == item.UserName && x.Password == item.Password && x.IsActive == true && x.Role == UserRole.Member));
            //    return RedirectToAction("ProductList", "Member");  // todo: sonradan eklendi
            //}

            // Furkan Test Islemlerı Test1 :)
            #endregion

            try
            {
                foreach (AppUser item2 in arep.GetAll())
                {
                    string cozulmusSifre = DantexCrypt.DeCrypt(item2.Password);
                    if (arep.Any(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Member) == true)
                    {
                        Session["member"] = arep.Where(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Member).FirstOrDefault();

                        AppUser kullanici = Session["member"] as AppUser;
                        return(RedirectToAction("ProductList", "Member"));
                    }
                }

                ViewBag.Hatali = "Kullanıcı Bilgileri Hatalı. Kayıtlı Değilseniz: ";
                return(View());
            }
            catch (Exception)
            {
                ViewBag.Hatali = "Kullanıcı Bilgileri Hatalı. Kayıtlı Değilseniz: ";
                return(View());
            }
        }
コード例 #4
0
        public ActionResult Login(AppUser item)
        {
            try
            {
                foreach (AppUser item2 in arep.GetAll())
                {
                    string cozulmusSifre = DantexCrypt.DeCrypt(item2.Password);

                    if (arep.Any(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Admin) == true)
                    {
                        Session["admin"] = arep.Where(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Admin).FirstOrDefault();

                        AppUser kullanici = Session["admin"] as AppUser;
                        return(RedirectToAction("ListProduct", "Product"));
                    }
                }

                ViewBag.Hatali = "Hatalı giriş yaptınız.";
                return(View());
            }
            catch (Exception)
            {
                ViewBag.Hatali = "Hatalı giriş yaptınız";
                return(View());
            }
        }
コード例 #5
0
        public ActionResult Login(AppUser appUser)
        {
            AppUser yakalanan = _apRep.FirstOrDefault(x => x.UserName == appUser.UserName);

            if (yakalanan == null)
            {
                ViewBag.Kullanici = "Kullanıcı bulunamadı";
                return(View());
            }
            string decrypted = DantexCrypt.DeCrypt(yakalanan.Password);

            if (appUser.Password == decrypted && yakalanan.Role == ENTITIES.Enums.UserRole.Admin)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["admin"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category", new { Area = "Admin" }));
            }
            else if (yakalanan.Role == ENTITIES.Enums.UserRole.Member)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["member"] = yakalanan;
                return(RedirectToAction("ShoppingList", "Shopping"));
            }

            ViewBag.Kullanici = "Kullanici bulunamadı";
            return(View());
        }
コード例 #6
0
        public ActionResult Login(AppUser item)
        {
            if (arep.Any(x => x.UserName == item.UserName && DantexCrypt.DeCrypt(x.Password) == item.Password && x.Role == MODEL.Enums.UserRole.Admin))
            {
                Session["admin"] = arep.FirstOrDefault(x => x.UserName == item.UserName && x.Password == item.Password && x.Role == MODEL.Enums.UserRole.Admin);

                return(RedirectToAction("ListProduct", "Product"));
            }
            ViewBag.Hata = "Hatalı Giriş Yaptınız.";
            return(View());
        }
コード例 #7
0
 public AppUser KontrolEt(string kullaniciadi, string sifre)
 {
     foreach (AppUser item in db.AppUsers.Where(x => x.IsActive == true))
     {
         string veritabaniSifre = DantexCrypt.DeCrypt(item.Password);
         if (Any(x => x.UserName == kullaniciadi && veritabaniSifre == sifre && x.Role == UserRole.Member && x.IsActive == true))
         {
             return(Where(x => x.UserName == kullaniciadi && veritabaniSifre == sifre && x.Role == UserRole.Member && x.IsActive == true).Single());
         }
     }
     return(null);
 }
コード例 #8
0
        public ActionResult Login(AppUser item)
        {
            AppUser yakalanan = apRep.Default(x => x.UserName == item.UserName);

            string decrypted = DantexCrypt.DeCrypt(yakalanan.Password);

            if (item.Password == decrypted && yakalanan != null && yakalanan.Role == MODEL.Enums.UserRole.Admin)
            {
                if (!yakalanan.IsActive)
                {
                    AktifKontrol();
                }
                Session["admin"]     = yakalanan;
                Session["LogMember"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category", new { area = "Admin" }));
            }

            else if (item.Password == decrypted && yakalanan != null && yakalanan.Role == MODEL.Enums.UserRole.Member)
            {
                if (!yakalanan.IsActive)
                {
                    AktifKontrol();
                }

                Session["member"]    = yakalanan;
                Session["LogMember"] = yakalanan;
                return(RedirectToAction("ShoppingList", "Shopping"));
            }

            if (yakalanan != null)
            {
                LogRepository lrep        = new LogRepository();
                Log           sifreYanlis = new Log();
                sifreYanlis.Description = KeyWord.Exit;
                sifreYanlis.Information = $"{item.UserName} adlı kullanıcı şifresini {DateTime.Now} tarihinde yanlış girdi.";
                lrep.Add(sifreYanlis);
            }



            TempData["KullaniciYok"] = "Kullanıcı veya şifre yanlış.";
            return(View());
        }
コード例 #9
0
        public ActionResult Login([Bind(Prefix = "AppUser")] AppUser item)
        {
            AppUser loginUser = apRep.FirstOrDefault(x => x.Email == item.Email);


            if (loginUser == null) //Eğer sorgudan kullanıcı gelmiyorsa
            {
                ViewBag.Hata = "Bu email adresine kayıtlı kullanıcı bulunamadı";
                return(View());
            }

            string decrypted = DantexCrypt.DeCrypt(loginUser.Password);



            if (loginUser != null && item.Password == decrypted && loginUser.Role == ENTITIES.Enums.UserRole.Member)
            {
                if (!loginUser.Active)
                {
                    return(AktifKontrol());
                }
                Session["member"] = loginUser;
                return(RedirectToAction("Index", "Home"));
            }//If catched user is a member
            else if (loginUser != null && item.Password == decrypted && loginUser.Role == ENTITIES.Enums.UserRole.Vip)
            {
                if (!loginUser.Active)
                {
                    return(AktifKontrol());
                }
                Session["vip"] = loginUser;
                return(RedirectToAction("Index", "Home"));
            }//If catched user is a vip



            else
            {
                ViewBag.Hata = "Email adresi veya şifrenizi hatalı girdiniz.";
                return(View());
            }
        }
コード例 #10
0
        public ActionResult EmployeeLogin([Bind(Prefix = ("Employee"))] Employee item)
        {
            Employee loginEmployee = _empRep.FirstOrDefault(x => x.Email == item.Email);

            string decrypted = DantexCrypt.DeCrypt(loginEmployee.Password);

            if (loginEmployee == null)
            {
                ViewBag.Hata = "Bu email adresine kayıtlı çalışan bulunamadı";
                return(View());
            }
            else
            {
                if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.Boss)
                {
                    Session["boss"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a boss
                else if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.Management)
                {
                    Session["management"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a management
                else if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.BookingClerk)
                {
                    Session["bookingClerk"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a bookingClerk
                else if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.BoxOfficeSupervisor)
                {
                    Session["boxSupervisor"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a boxSupervisor
                else
                {
                    ViewBag.Hata = "Email adresi veya şifrenizi hatalı girdiniz.";
                    return(View());
                }
            }
        }
コード例 #11
0
        public ActionResult Login(AppUser item)
        {
            AppUser user      = apRep.Default(x => x.UserName == item.UserName);
            string  decrypted = DantexCrypt.DeCrypt(user.Password);

            if (item.Password == decrypted && user != null)
            {
                if (user.Role == UserRole.Admin)
                {
                    if (!user.IsActive)
                    {
                        ActiveControl();
                    }
                    else
                    {
                        Session["admin"] = user;
                        return(RedirectToAction("Index", "AdminHome", new { area = "Admin" }));
                    }
                }
                else if (user.Role == UserRole.Member)
                {
                    if (!user.IsActive)
                    {
                        ActiveControl();
                    }
                    else
                    {
                        Session["member"] = user;
                        return(RedirectToAction("Index", "Shopping"));
                    }
                }
            }
            else
            {
                ViewBag.UserNull = "Kullanıcı Bulunamadı";
            }
            return(View(user));
        }
コード例 #12
0
        public ActionResult Login(AppUser appUser)
        {
            AppUser account = appRep.FirstOrDefault(x => x.UserName == appUser.UserName || x.Email == appUser.Email);
            //kullanıcı adı ya da email

            string decrypted = DantexCrypt.DeCrypt(account.Password);

            if (appUser.Password == decrypted && account != null && account.URole == ENTITIES.Enums.UserRole.Member)
            {
                if (!account.Active)
                {
                    return(ActiveControl());
                }

                //FormsAuthentication.SetAuthCookie(appUser.UserName, appUser.RememberMe);
                //Beni hatırla butonu için
                Session["member"] = account;
                return(RedirectToAction("ShoppingList", "Shopping"));
                //Burada ShoppingList vardı
            }

            ViewBag.KullaniciYok = "Kullanıcı Bulunamadı";
            return(View());
        }
コード例 #13
0
        public ActionResult Add([Bind(Prefix = "item1")] AppUser item, [Bind(Prefix = "item2")] AppUserDetail item2)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }   //Kullanıcı tarayıcının JS kapatıp giriş yapmak isteyebilir.

            if (item != null && item2 != null)
            {
                if (arep.Any(x => x.UserName != item.UserName && DantexCrypt.DeCrypt(x.Password) != item.Password && x.Email != item.Email))
                {
                    item.Role = UserRole.Admin;
                    arep.Add(item);
                    item2.ID = item.ID;
                    adrep.Add(item2);
                    MailSender.Send(item.Email, body: $"{"http://localhost:60442/Home/RegisterOnay/"}{item.ActivationCode}", subject: "Doğrulama Kodu");
                    return(View("List"));
                }
                ViewBag.ZatenVar = "Böyle bir kullanıcı zaten var.";
                return(View());
            }
            ViewBag.Hata = "Kullanıcı oluşturulurken hata oluştu.";
            return(View());
        }