Esempio n. 1
0
        public void Update(Entities.User entity)
        {
            var sifre = new ToPasswordRepository().Sha1(entity.Password);

            entity.Password = sifre;
            _userDal.Update(entity);
        }
Esempio n. 2
0
 public Customer KullaniciGiris(string kullaniciadi, string parola)
 {
     try
     {
         var sifre          = new ToPasswordRepository().Md5(parola);
         var kullanici      = db.Customer.Where(x => x.Cname == kullaniciadi && x.Password == sifre).FirstOrDefault();
         var kullaniciemail = db.Customer.Where(x => x.EmailAdress == kullaniciadi && x.Password == sifre).FirstOrDefault();
         if (kullaniciemail != null)
         {
             return(kullaniciemail);
         }
         if (kullanici != null)
         {
             return(kullanici);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception error)
     {
         throw new Exception("Kullanici Giriş Hata:" + error.Message);
     }
 }
        public ActionResult UyeOl(UyeBilgileri bilgi)
        {
            var sifre = new ToPasswordRepository().Md5(bilgi.parola);


            _customeradresservice.Add(new CustomersAdress {
                CustomerAdress = bilgi.adres
            });
            var sonkisi = _customeradresservice.GetAll().LastOrDefault();

            _customerservice.Add(new Customer
            {
                Cname             = bilgi.isim,
                UserName          = bilgi.soyisim,
                CountryName       = bilgi.ulke,
                CityName          = bilgi.il,
                CountyName        = bilgi.ilce,
                NeighborhoodName  = bilgi.semt,
                Password          = sifre,
                EmailAdress       = bilgi.Email,
                CustomersAdressId = sonkisi.Id
            });

            return(RedirectToAction("GirisYap"));
        }
Esempio n. 4
0
        public Entity.Models.Kullanici KullaniciGiris(string kullaniciAdi, string kullaniciSifre)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(kullaniciAdi.Trim()) || String.IsNullOrWhiteSpace(kullaniciAdi.Trim()))
                {
                    throw new Exception("Kullanıcı Adı ve Sifre Boş Geçilemez");
                }

                var sifre = new ToPasswordRepository().Md5(kullaniciSifre);
                Entity.Models.Kullanici kullanici = _kullaniciDal.KullaniciGiris(kullaniciAdi, sifre);

                if (kullanici == null)
                {
                    throw new Exception("Kullanıcı Adı veya Şifre Hatalı");
                }
                else
                {
                    return(kullanici);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Kullanıcı giriş Hata : " + e.Message);
            }
        }
        public Kullanici KullaniciGiris(string kullaniciAdi, string parola)
        {
            try
            {
                if (string.IsNullOrEmpty(kullaniciAdi.Trim()) || string.IsNullOrEmpty(parola.Trim()))
                {
                    throw new Exception("Kullanici Adı veya parola Boş geçilemez");
                }

                var sifre     = new ToPasswordRepository().Md5(parola);
                var kullanici = _kullaniciDal.KullaniciGiris(kullaniciAdi, sifre);
                if (kullanici == null)
                {
                    throw new Exception("Kullanici ve Parola hatalı");
                }
                else
                {
                    return(kullanici);
                }
            }
            catch (Exception error)
            {
                throw new Exception("Hata olustu" + error.Message);
            }
        }
Esempio n. 6
0
        public IActionResult Index(UserViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.Password = ToPasswordRepository.PasswordCryptographyCombine(model.Password);

                User foundUser = userService.Get(x => x.UserName.Equals(model.UserName) && x.Password.Equals(model.Password));
                if (foundUser != null)
                {
                    foundUser.UpdateDate   = DateTime.UtcNow;
                    foundUser.UpdateUserid = foundUser.id;
                    userService.Update(foundUser);
                    userService.Save();
                    SessionUser session = new SessionUser();
                    foundUser.UserToSession(ref session);
                    userSessionService.Set(session, "LoginUser");
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }
                else
                {
                    ViewBag.AlertMassage = "Girdiginiz bilgiler ile eslesen bir kayit bulunamadi.";
                }
            }
            else
            {
                ViewBag.AlertMassage = "Lutfen bilgileri dogru giriniz.";
            }
            return(View(model));
        }
Esempio n. 7
0
        public IActionResult Login(LoginViewModel model)
        {
            if (!string.IsNullOrWhiteSpace(model.Password) && _userService.GetMany(user => user.Email.Equals(model.Email) && user.Role != 2).Count > 0)
            {
                model.Password = ToPasswordRepository.PasswordCryptographyCombine(model.Password);
                User res = _userService.GetMany(x => x.Email == model.Email && x.Role != 2).First();
                if (res.Password != model.Password)
                {
                    TempData["message"]  = "Hata";
                    TempData["message2"] = "Girdiğiniz parolalar eşleşmiyor.";
                    goto Finish;
                }

                if (res.IsActive == true)
                {
                    if (res.Role != 2)
                    {
                        res.UpdateDate   = DateTime.UtcNow;
                        res.UpdateUserid = res.id;
                        _userSessionService.Set(res, "LoginAdmin");
                        TempData["message"]  = "Başarılı";
                        TempData["message2"] = "Giriş başarılı.";
                        _userService.Update(res);
                        _userService.Save();

                        return(RedirectToAction("Index", "Home", new { area = "Admin" }));
                    }
                    else
                    {
                        TempData["message"]  = "Hata";
                        TempData["message2"] = "Yetersiz Yetki";
                    }
                }
                else
                {
                    TempData["message"]  = "Hata";
                    TempData["message2"] = "Lütfen hesabınızın onaylanmasını bekleyin.";
                    goto Finish;
                }
            }
            else
            {
                TempData["message"]  = "Hata";
                TempData["message2"] = "Kullanıcı adı veya şifre hatalı.";
                goto Finish;
            }



Finish:

            return(View());
        }
Esempio n. 8
0
        public IActionResult Register(RegisterViewModel model)
        {
            TempData["errorMessage"] = "";
            if (ModelState.IsValid)
            {
                if (model.Password != model.PasswordConfirmation)
                {
                    TempData["errorMessage"] += "Şifreler birbiriyle uyuşmamaktadır.\n";
                }
                if (_userService.GetMany(user => user.Email.Equals(model.Email) && user.Role != 2).Count > 0)
                {
                    TempData["errorMassage"] += "Bu mail adresi daha önceden kayıtlıdır.";
                }
                else
                {
                    model.Password = ToPasswordRepository.PasswordCryptographyCombine(model.Password);

                    User user = new User()
                    {
                        Firstname = model.FirstName,
                        Lastname  = model.LastName,
                        Password  = model.Password,
                        Email     = model.Email,
                        TagName   = model.UserName,
                        Role      = 2,
                    };

                    try
                    {
                        _userService.Add(user);
                        _userService.Save();
                    }
                    catch
                    {
                        TempData["errorMassage"] += "Veri tabanına eklerken hata ile karşılaşıldı.";
                    }
                }
            }
            else
            {
                TempData["errorMassage"] = "Tüm değerleri doğru biçimde giriniz";
            }
            return(RedirectToAction("Login", "Home", new { area = "Admin" }));
        }
Esempio n. 9
0
 public Kullanici GirisYap(string kullaniciAdi, string parola)
 {
     try
     {
         var sifre = new ToPasswordRepository().Md5(parola);
         var user  = _kullaniciDal.GirisYap(kullaniciAdi, sifre);
         if (user == null)
         {
             throw new Exception("Kullanıcı veya Parola Uyuşmuyor.");
         }
         else
         {
             return(user);
         }
     }
     catch (Exception)
     {
         throw new Exception("Kullanıcı Giriş Hatası");
     }
 }
        public ActionResult SifreSifirlama(KullaniciModel model)
        {
            var      sifre = new ToPasswordRepository().Md5(model.Yenisifre);
            Customer verim = new Customer();

            verim.Cname    = model.Customer.Cname;
            verim.UserName = model.Customer.UserName;
            verim.Password = model.Yenisifre;
            var kullan = _customerservice.GetKullaniciKullaniciName(model.Customer.UserName);

            kullan.Cname             = model.Customer.Cname;
            kullan.Password          = sifre;
            kullan.UserName          = model.Customer.UserName;
            kullan.CityName          = model.Customer.CityName;
            kullan.CountryName       = model.Customer.CountryName;
            kullan.CountyName        = model.Customer.CountyName;
            kullan.NeighborhoodName  = model.Customer.NeighborhoodName;
            kullan.CustomersAdressId = model.Customer.CustomersAdressId;
            _customerservice.Update(kullan);

            TempData["sifresifirla"] = "  Şifre sıfırlama işlemi gerçekleşmiştir...";
            return(RedirectToAction("GirisYap"));
        }
        public async Task <IActionResult> SignUp(AppUserAddFormDto appUserAddDto)
        {
            if (ModelState.IsValid)
            {
                AppUser appUser = await appUserService.FindByUserName(appUserAddDto.UserName);

                if (appUser != null)
                {
                    logger.LogInformation($"{appUser.UserName} Kullanici adi zaten alınmış");
                    ModelState.AddModelError("", $"{appUser.UserName} kullanıcı adı zaten alınmış");
                    return(View(appUserAddDto));
                }

                appUserAddDto.Password = ToPasswordRepository.PasswordCryptographyCombine(appUserAddDto.Password);
                appUser = mapper.Map <AppUser>(appUserAddDto);
                await userService.AddAsync(appUser);

                logger.LogInformation($"{appUser.UserName} Kullanici olusturuldu");

                AppRole memberRole = await appRoleService.FindByName(RoleInfo.Member);

                await userRoleService.AddAsync(new UserRole()
                {
                    AppRoleId = memberRole.Id,
                    AppUserId = appUser.Id
                });

                logger.LogInformation($"{appUser.UserName} Kullanicisina varsayilan rol bilgisi eklendi");
                return(RedirectToAction("SignIn"));
            }
            else
            {
                logger.LogInformation("AppUserAddDto Not Valid");
                ModelState.AddModelError("", "Lütfen gereken tüm alanları doldurunuz.");
                return(View(appUserAddDto));
            }
        }
Esempio n. 12
0
 public Entities.User userLogin(string EMail, string Password)
 {
     try
     {
         if (string.IsNullOrEmpty(EMail.Trim()) || string.IsNullOrEmpty(Password.Trim()))
         {
             throw new Exception("EMail veya Parola Boş Geçilemez..");
         }
         var sifre = new ToPasswordRepository().Sha1(Password);
         var user  = _userDal.userLogin(EMail, sifre);
         if (user == null)
         {
             throw new Exception("Kullanıcı ve Parola Uyuşmuyor");
         }
         else
         {
             return(user);
         }
     }
     catch (Exception)
     {
         throw new Exception("Kullanıcı Giriş Hata :");
     }
 }
Esempio n. 13
0
 public bool CheckPassword(AppUserLoginDto appUserLoginDto, AppUser appUser)
 {
     return(appUser?.Password == ToPasswordRepository.PasswordCryptographyCombine(appUserLoginDto?.Password));
 }