Example #1
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 AddAppUser(AppUser item, HttpPostedFileBase resim)
 {
     if (app_repo.Any(x => x.UserName == item.UserName || x.Email == item.Email) || editor_repo.Any(x => x.UserName == item.UserName || x.Email == item.Email) || columnist_repo.Any(x => x.Email == item.Email))
     {
         ViewBag.Kayitli = "Böyle bir kullanıcı zaten mevcut";
         return(View());
     }
     item.CreatedBy = (Session["admin"] as AppUser).UserName;
     item.ImagePath = ImageUploader.UploadImage("~/Pictures", resim);
     item.Password  = Crypto.HashPassword(item.Password);
     item.UserIP    = Request.UserHostAddress;
     app_repo.Add(item);
     return(RedirectToAction("ListAppUser"));
 }
Example #3
0
 public ActionResult AddAppUser([Bind(Prefix = "Item1")] AppUser item, [Bind(Prefix = "Item2")] AppUserDetail item2)
 {
     if (apprep.Any(x => x.UserName == item.UserName || x.Email == item.Email))
     {
         ViewBag.Kayitli = "Böyle bir kullanıcı zaten mevcut";
         return(View());
     }
     item.CreatedBy = (Session["admin"] as AppUser).UserName;
     item.Password  = Crypto.HashPassword(item.Password);
     item2.UserIP   = Request.UserHostAddress;
     apprep.Add(item);
     item.ID = item2.ID;
     appdetrepo.Add(item2);
     return(RedirectToAction("ListAppUser"));
 }
Example #4
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))
     {
         ChooseForm adminForm = new ChooseForm();
         this.Hide();
         adminForm.Show();
     }
     else
     {
         MessageBox.Show("Kullanıcı bulunamadı!!");
     }
 }
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            if (!ModelState.IsValid)
            {
                return(View("RegisterNow"));
            }
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.UserProfile;

            appUser.Password        = DantexCrypt.Crypt(appUser.Password);
            appUser.ConfirmPassword = DantexCrypt.Crypt(appUser.ConfirmPassword);
            //Kayıt işlemi
            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "Kullanıcı ismi alınmış";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "Email kayıtlı";
                return(View());
            }

            //Başarılı kayıt sonrası mail gönderme işlemi
            string register = "Tebrikler, hesabınız oluşturulmuştur. Hesabınızı aktive etmek için https://localhost:44317/Register/Activation/" + appUser.ActivationCode + " linkine tıklayabilirsiniz.";

            MailSender.Send(appUser.Email, body: register, subject: "Hesap Aktivasyon!");
            apRep.Add(appUser);

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName) || !string.IsNullOrEmpty(profile.Address) || !string.IsNullOrEmpty(profile.Phone))
            {
                profile.ID = appUser.ID;
                usRep.Add(profile);
            }
            return(View("RegisterSuccess"));
        }
Example #6
0
        public void Add(AppUserAddVM model)
        {
            if (AppUserRepository.Any(x => x.Login == model.Login))
            {
                throw new BussinesException(1000, ErrorResource.UserAlreadyAdded);
            }
            Language language = LanguageRepository.GetSingle(x => x.CultureSymbol == "pl-PL");
            AppUser  user     = new AppUser()
            {
                CreatedById = MainContext.PersonId,
                CreatedDate = DateTime.Now,
                IsActive    = model.IsActive,
                LastName    = model.LastName,
                FirstName   = model.FirstName,
                Login       = model.Login,
                LanguageId  = language.Id,
            };

            AppUserRepository.Add(user);
            AppUserRepository.Save();

            if (model.Role == AppRoleType.Administrator)
            {
                AppRole admin = AppRoleRepository.GetSingle(x => x.AppRoleType == AppRoleType.Administrator);
                if (admin == null)
                {
                    admin = AppRoleService.AddRole(AppRoleType.Administrator, "Administratorzy", "Grupa administratorów systemu");
                }
                AppUserRole appUserRole = new AppUserRole()
                {
                    AppRoleId = admin.Id,
                    AppUserId = user.Id,
                };
                AppUserRoleRepository.Add(appUserRole);
            }
            AppUserRoleRepository.Save();
        }
        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());
        }
Example #8
0
 public ActionResult AddColumnist(Columnist item, HttpPostedFileBase resim)
 {
     if (col_repo.Any(x => x.UserName == item.UserName || x.Email == item.Email) || editor_repo.Any(x => x.UserName == item.UserName || x.Email == item.Email) || app_repo.Any(x => x.UserName == item.UserName || x.Email == item.Email))
     {
         ViewBag.Mevcut = "Böyle bir kullanıcı mevcut";
         return(View());
     }
     item.CreatedBy = (Session["admin"] as AppUser).UserName;
     item.ImagePath = ImageUploader.UploadImage("~/Pictures/Users", resim);
     item.Password  = Crypto.HashPassword(item.Password);
     col_repo.Add(item);
     return(RedirectToAction("ListColumnist"));
 }
Example #9
0
 public ActionResult Login(AppUser item, string Remember)
 {
     if (App_repo.Any(x => x.UserName == item.UserName && x.Role == Role.Admin && x.Status != DataStatus.Deleted))
     {
         AppUser girenKisi = App_repo.Default(x => x.UserName == item.UserName && x.Role == Role.Admin);
         if (girenKisi.IsBanned == true)
         {
             ViewBag.Banli = "Banlandın!";
             return(View());
         }
         bool result = Crypto.VerifyHashedPassword(girenKisi.Password, item.Password);
         if (result)
         {
             RememberMe(item, Remember);
             Session["admin"] = girenKisi;
             return(RedirectToAction("NewsList", "Member"));
         }
     }
     else if (App_repo.Any(x => x.UserName == item.UserName && x.Role == Role.Member))
     {
         AppUser girenUye = App_repo.Default(x => x.UserName == item.UserName);
         if (girenUye.IsBanned == true)
         {
             ViewBag.Banli = "Banlandın!";
             return(View());
         }
         bool result = Crypto.VerifyHashedPassword(girenUye.Password, item.Password);
         if (result)
         {
             RememberMe(item, Remember);
             Session["member"] = girenUye;
             return(RedirectToAction("NewsList", "Member"));
         }
     }
     else if (Editor_repo.Any(x => x.UserName == item.UserName))
     {
         Editor girenEditor = Editor_repo.Default(x => x.UserName == item.UserName);
         if (girenEditor.IsBanned == true)
         {
             ViewBag.Banli = "Banlandın!";
             return(View());
         }
         bool result = Crypto.VerifyHashedPassword(girenEditor.Password, item.Password);
         if (result)
         {
             RememberMe(item, Remember);
             Session["editor"] = girenEditor;
             return(RedirectToAction("NewsList", "Member"));
         }
     }
     else if (Columnist_repo.Any(x => x.UserName == item.UserName))
     {
         Columnist girenYazar = Columnist_repo.Default(x => x.UserName == item.UserName);
         if (girenYazar.IsBanned == true)
         {
             ViewBag.Banli = "Banlandın!";
             return(View());
         }
         bool result = Crypto.VerifyHashedPassword(girenYazar.Password, item.Password);
         if (result)
         {
             RememberMe(item, Remember);
             Session["columnist"] = girenYazar;
             return(RedirectToAction("NewsList", "Member"));
         }
     }
     ViewBag.Message = "Hatalı kullanıcı adı veya şifre";
     return(View());
 }