Exemple #1
0
 public ActionResult AddEditor(Editor 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());
     }
     if (item.ImagePath != null)
     {
         item.ImagePath = ImageUploader.UploadImage("~/Pictures", resim);
     }
     item.CreatedBy = (Session["admin"] as AppUser).UserName;
     item.Password  = Crypto.HashPassword(item.Password);
     editor_repo.Add(item);
     return(RedirectToAction("ListEditor"));
 }
Exemple #2
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());
 }
 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"));
 }