Ejemplo n.º 1
0
 private void BtnGiris_Click(object sender, EventArgs e)
 {
     if (appUserRepository.Any(x => x.UserName == txtUserName.Text &&
                               x.Password == txtPassword.Text &&
                               x.Role == MODEL.Enums.UserRole.Admin))
     {
         AdminForm adminForm = new AdminForm(appUserRepository.FirstOrDefault(x => x.UserName == txtUserName.Text &&
                                                                              x.Password == txtPassword.Text &&
                                                                              x.Role == MODEL.Enums.UserRole.Admin));
         this.Hide();
         adminForm.Show();
     }
     else if (appUserRepository.Any(x => x.UserName == txtUserName.Text &&
                                    x.Password == txtPassword.Text &&
                                    x.Role == MODEL.Enums.UserRole.Employee))
     {
         EmployeeForm employeeForm = new EmployeeForm(appUserRepository.FirstOrDefault(x => x.UserName == txtUserName.Text &&
                                                                                       x.Password == txtPassword.Text &&
                                                                                       x.Role == MODEL.Enums.UserRole.Employee));
         this.Hide();
         employeeForm.Show();
     }
     else
     {
         MessageBox.Show("Unidentified User!");
     }
 }
Ejemplo n.º 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());
        }
Ejemplo n.º 3
0
        public ActionResult UpdateUser(AppUserVM apvm)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            AppUser     toBeUpdatedUser        = _uRep.FirstOrDefault(x => x.ID == apvm.AppUser.ID);
            UserProfile toBeUpdatedUserProfile = _upRep.FirstOrDefault(x => x.ID == apvm.UserProfile.ID);



            toBeUpdatedUser.Email           = apvm.AppUser.Email;
            toBeUpdatedUser.Password        = apvm.AppUser.Password;
            toBeUpdatedUser.ConfirmPassword = apvm.AppUser.ConfirmPassword;
            toBeUpdatedUser.Role            = apvm.AppUser.Role;

            toBeUpdatedUserProfile.FirstName   = apvm.UserProfile.FirstName;
            toBeUpdatedUserProfile.LastName    = apvm.UserProfile.LastName;
            toBeUpdatedUserProfile.MobilePhone = apvm.UserProfile.MobilePhone;
            toBeUpdatedUserProfile.Gender      = apvm.UserProfile.Gender;
            toBeUpdatedUserProfile.Address     = apvm.UserProfile.Address;


            _uRep.Update(toBeUpdatedUser);
            _upRep.Update(toBeUpdatedUserProfile);

            TempData["updateUser"] = $"{toBeUpdatedUserProfile.FirstName} {toBeUpdatedUserProfile.LastName} kişisi başarıyla güncellenmiştir";


            return(RedirectToAction("UserList", "User", new { Area = "Panel" }));
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
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());
            }
        }
Ejemplo n.º 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());
        }
        public ActionResult Update(int id)
        {
            AppUser       a  = arep.FirstOrDefault(x => x.ID == id && x.Status != DataStatus.Deleted);
            AppUserDetail ad = adrep.FirstOrDefault(x => x.ID == id && x.Status != DataStatus.Deleted);

            if (a != null) //Veri başka bir admin tarafından silinmiş olabilir. Bu durumda null gelme olasılığı bulunmakatadır.
            {
                return(View(Tuple.Create(a, ad)));
            }

            ViewBag.Bulunamadı = "Veri güncellenmek istenirken hata ile karşılaşıldı.";
            return(View());
        }
 public void OnGet()
 {
     if (HttpContext.User.Identity.IsAuthenticated)
     {
         AppUserRepository userRepository = new AppUserRepository(HttpContext.User.Identity.Name); // email actually
         userRepository.Initialize();
         AppUser = userRepository.FirstOrDefault();
         //
         FurnitureRepository furnitureRepository = new FurnitureRepository(QueryMode.Recommendations, AppUser.ID.ToString());
         furnitureRepository.Initialize();
         Recommendations = furnitureRepository.Items.Take(3).ToList();
     }
 }
        public ActionResult RegisterOnay(Guid id)
        {
            AppUser kullanici = arep.FirstOrDefault(x => x.ActivationCode == id);

            if (kullanici != null)
            {
                kullanici.IsActive = true;
                arep.Update(kullanici);
                TempData.Add("HesapAktif", $"{kullanici.UserName} Hesabınız Zaten Aktif");
                return(RedirectToAction("Login")); // todo: sonradan eklendi
            }
            ViewBag.mailonay = "Doğrulama Yapılamadı";
            return(RedirectToAction("Register"));
        }   //Üye onay işlemleri
Ejemplo n.º 10
0
        public ActionResult Add(AppUser model)
        {
            var EncypePassword   = CryptoService.PasswordHash(model.PasswordHash);
            var dataBasePassword = appUserRepo.FirstOrDefault(x => x.ID == 4).PasswordHash;

            if (EncypePassword == dataBasePassword)
            {
                // kullanıcı şifreyi değiştirebilir
            }
            appUserRepo.Insert(model);
            ViewBag.IsSuccess = appUserRepo.Save() > 0 ? true : false;

            return(View());
        }
Ejemplo n.º 11
0
        public ActionResult Activation(Guid id)
        {
            AppUser aktifEdilecek = _apRep.FirstOrDefault(x => x.ActivationCode == id);

            if (aktifEdilecek != null)
            {
                aktifEdilecek.Active = true;
                _apRep.Update(aktifEdilecek);
                TempData["HesapAktifMi"] = "Hesabınız aktif hale getirildi";
                return(RedirectToAction("Login", "Home"));
            }
            TempData["HesapAktifMi"] = "Hesabınız bulunamadı";
            return(RedirectToAction("Login", "Home"));
        }
        public ActionResult Activation(Guid id)
        {
            AppUser aktifEdilecek = apRep.FirstOrDefault(x => x.ActivationCode == id);

            if (aktifEdilecek != null)
            {
                aktifEdilecek.Active = true;
                apRep.Update(aktifEdilecek);

                TempData["HesapAktifmi"] = "Your account has been activated";
                return(RedirectToAction("Login", "Home"));
            }
            TempData["HesapAktifmi"] = "No account to activate";
            return(RedirectToAction("Login", "Home"));
        }
Ejemplo n.º 13
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());
        }
Ejemplo n.º 14
0
        public ActionResult Activation(Guid id)
        {
            AppUser hesapAktif = apRep.FirstOrDefault(x => x.ActivationCode == id);

            if (hesapAktif != null)
            {
                hesapAktif.Active         = true;
                hesapAktif.ActivationCode = Guid.NewGuid();
                apRep.Update(hesapAktif);

                TempData["HesapAktifmi"] = "Hesap aktivasyonu tamamlandı";
                return(RedirectToAction("Login", "Account"));
            }
            TempData["HesapAktifmi"] = "Aktif edilecek hesap bulunamadı";
            return(RedirectToAction("Login", "Account"));
        }
        public async Task <IActionResult> OnPostLogin()
        {
            AppUserRepository userRepository = new AppUserRepository();

            if (ModelState.IsValid)
            {
                bool verified = userRepository.VerifyUser(LoginForm.Email, LoginForm.Password);
                if (verified)
                {
                    userRepository = new AppUserRepository(LoginForm.Email);
                    userRepository.Initialize();
                    await Authenticate(LoginForm.Email, userRepository.FirstOrDefault().IsAdmin); // аутентификация

                    return(Redirect("/Index"));
                }
                Message          = "Некорректные логин и/или пароль.";
                IsWarningMessage = true;
            }
            return(RedirectToPage());
        }