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());
            }
        }
Beispiel #2
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());
            }
        }
Beispiel #3
0
        public List <AppUser> GetAllAppUser(Expression <Func <AppUser, bool> > Predicate)
        {
            try
            {
                AppUserRepository repository = new AppUserRepository(context);
                List <AppUser>    list       = repository.GetAll(Predicate);

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #4
0
        public List <AppUser> GetAllAppUser()
        {
            try
            {
                AppUserRepository repository = new AppUserRepository(context);
                List <AppUser>    list       = repository.GetAll();

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #5
0
        public List <LdapUser> FindUserDirectory(LdapUser user)
        {
            try
            {
                List <LdapUser> listUser   = GetAllUsersDirectory();
                List <LdapUser> returnList = new List <LdapUser>();

                AppUserRepository appUserRepository = new AppUserRepository(context);
                List <AppUser>    listAppUser       = appUserRepository.GetAll();

                if (user.UserName != "" && user.UserName != null)
                {
                    listUser = listUser.FindAll(x => x.UserName.Trim().ToLower().Contains(user.UserName.Trim().ToLower()));
                }

                if (user.Name != "" && user.Name != null)
                {
                    listUser = listUser.FindAll(x => x.Name.Trim().ToLower().Contains(user.Name.Trim().ToLower()));
                }

                if (user.Email != "" && user.Email != null)
                {
                    listUser = listUser.FindAll(x => x.Email.Trim().ToLower().Contains(user.Email.Trim().ToLower()));
                }


                foreach (LdapUser item in listUser)
                {
                    var apUserAux = listAppUser.Find(x => x.Name.Trim().ToLower() == item.UserName.Trim().ToLower());
                    if (apUserAux == null)
                    {
                        returnList.Add(item);
                    }
                }

                return(returnList);
            }
            catch (Exception ex)
            {
                string inner = string.Empty;
                if (ex.InnerException != null)
                {
                    inner = " inner: " + ex.InnerException.Message;
                }


                throw new Exception(ex.Message);
            }
        }
        public async Task <IActionResult> Profile(string UserName)
        {
            var users = await _userRepository.GetAll();

            AppUser          user      = users.Where(x => x.UserName == UserName).FirstOrDefault();
            AppUserViewModel viewModel = new()
            {
                FullName    = user.FirstName,
                UserName    = user.UserName,
                Location    = user.Location,
                Email       = user.Email,
                DateOfBirth = user.BirthDate.Date.ToShortDateString()
            };

            return(View(viewModel));
        }
    }
Beispiel #7
0
        public async Task <IActionResult> Search(string search_keyword)
        {
            try
            {
                List <AppUser> users = await _userRepository.GetAll();

                string term  = search_keyword;
                var    names = users.Where(p => (p.UserName.Contains(term)) || (p.FirstName.Contains(term)))
                               .Select(p => new { p.UserName, p.FirstName, p.Location })
                               .ToList();
                return(Json(new { data = names }));
            }
            catch
            {
                return(BadRequest());
            }
        }
Beispiel #8
0
        public ActionResult AppUserList(int?page, int?appUserID)
        {
            //AppUser appUser = aRep.Find();

            //string decrypted = DantexCrypt.DeCrypt(appUser.Password);

            AppUserVM avm = new AppUserVM
            {
                PagedOrders = appUserID == null?oRep.GetAll().ToPagedList(page ?? 1, 15) : oRep.Where(x => x.AppUserID == appUserID).ToPagedList(page ?? 1, 15),
                                  AppUsers = aRep.GetAll()
            };

            if (appUserID != null)
            {
                TempData["appID"] = appUserID;
            }
            return(View(avm));
        }
Beispiel #9
0
        public async Task <IActionResult> Login([FromForm] LoginViewModel loginViewModel)
        {
            try
            {
                List <AppUser> users = await _userRepository.GetAll();

                AppUser user = users.Where(x => (x.Email == loginViewModel.Identity || x.UserName == loginViewModel.Identity)).FirstOrDefault();
                if (user is not null)
                {
                    SecurityService.DecryptAndCheck(user.Password, user.SecretSalt, loginViewModel.PlainSecret);
                    HttpContext.Session.SetString(Constants.LoggedInUser, JsonConvert.SerializeObject(user));
                    return(RedirectToAction("Index", "Home"));
                }
                return(View());
            }
            catch (Exception ex)
            {
                if (ex is UnauthorizedAccessException)
                {
                    TempData["ERROR"] = ex.Message;
                }
                return(View());
            }
        }
Beispiel #10
0
        public AppUserData GetFirstUser()
        {
            AppUser user = AppUserRepository.GetSingle(x => x.Email == "*****@*****.**");

            if (user == null)
            {
                user = AppUserRepository.GetAll(x => x.LastName != null && x.LastName != "").OrderBy(x => x.LastName).FirstOrDefault();
            }
            AppUserData result = new AppUserData()
            {
                Id              = user.Id,
                FirstName       = user.FirstName,
                LastName        = user.LastName,
                UserName        = user.Email,
                Functionalities = EnumHelpers.GetEnumList <FunctionalityType>(),
                Language        = user.Language.LanguageDictionary,
                Login           = user.Login,
                IsActive        = user.IsActive,
                //Roles = EnumHelpers.GetEnumList<AppRoleType>(),
                Roles = user.AppUserRoles.Select(x => x.AppRole.AppRoleType).ToList()
            };

            return(result);
        }
Beispiel #11
0
        //LDAP

        public List <LdapUser> GetAllUsersDirectory()
        {
            try
            {
                List <LdapUser> listUsersActiveDirectory = new List <LdapUser>();
                string          DomainPath = "LDAP://DC=" + System.Configuration.ConfigurationManager.AppSettings["domainActiveDirectory"] + ",DC=" + System.Configuration.ConfigurationManager.AppSettings["domainActiveDirectoryExtension"];

                using (DirectoryEntry directoryEntry = new DirectoryEntry(DomainPath))
                {
                    DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry);
                    directorySearcher.PageSize = 10;
                    directorySearcher.Filter   = "(&(objectClass=user)(objectCategory=Person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
                    directorySearcher.PropertiesToLoad.Add("samaccountname");
                    directorySearcher.PropertiesToLoad.Add("title");
                    directorySearcher.PropertiesToLoad.Add("mail");
                    directorySearcher.PropertiesToLoad.Add("usergroup");
                    directorySearcher.PropertiesToLoad.Add("company");
                    directorySearcher.PropertiesToLoad.Add("department");
                    directorySearcher.PropertiesToLoad.Add("telephoneNumber");
                    directorySearcher.PropertiesToLoad.Add("mobile");
                    directorySearcher.PropertiesToLoad.Add("displayname");
                    SearchResult result;
                    LdapUser     itemUser;

                    SearchResultCollection iResult = directorySearcher.FindAll();


                    if (iResult != null)
                    {
                        AppUserRepository appUserRepository = new AppUserRepository(context);
                        List <AppUser>    listAppUser       = appUserRepository.GetAll();
                        //listAppUser.ForEach(x => x.Companys.ToList().ForEach(c => c.AppUsers = null));
                        for (int i = 0; i < iResult.Count; i++)
                        {
                            result = iResult[i];
                            if (result.Properties.Contains("samaccountname"))
                            {
                                itemUser = new LdapUser();

                                itemUser.UserName = (String)result.Properties["samaccountname"][0];

                                if (result.Properties.Contains("displayname"))
                                {
                                    itemUser.Name = (String)result.Properties["displayname"][0];
                                }
                                else
                                {
                                    itemUser.Name = string.Empty;
                                }

                                if (result.Properties.Contains("mail"))
                                {
                                    itemUser.Email = (String)result.Properties["mail"][0];
                                }
                                else
                                {
                                    itemUser.Email = string.Empty;
                                }

                                if (result.Properties.Contains("company"))
                                {
                                    itemUser.Company = (String)result.Properties["company"][0];
                                }

                                if (result.Properties.Contains("title"))
                                {
                                    itemUser.JobTitle = (String)result.Properties["title"][0];
                                }

                                if (result.Properties.Contains("department"))
                                {
                                    itemUser.Deparment = (String)result.Properties["department"][0];
                                }

                                if (result.Properties.Contains("telephoneNumber"))
                                {
                                    itemUser.Phone = (String)result.Properties["telephoneNumber"][0];
                                }

                                if (result.Properties.Contains("mobile"))
                                {
                                    itemUser.Mobile = (String)result.Properties["mobile"][0];
                                }

                                AppUser auxAppUser = listAppUser.Find(x => x.Name == itemUser.UserName);

                                if (auxAppUser != null)
                                {
                                    itemUser.Exists = true;
                                    //if (auxAppUser.Profile != null)
                                    //{
                                    //    itemUser.Profile = auxAppUser.Profile;
                                    //}

                                    //itemUser.Companys = auxAppUser.Companys;

                                    //itemUser.Active = auxAppUser.Active;
                                }

                                listUsersActiveDirectory.Add(itemUser);
                            }
                        }
                    }

                    directorySearcher.Dispose();
                    directoryEntry.Dispose();

                    return(listUsersActiveDirectory);
                }
            }
            catch (Exception ex)
            {
                string inner = string.Empty;
                if (ex.InnerException != null)
                {
                    inner = " inner: " + ex.InnerException.Message;
                }


                throw new Exception(ex.Message);
            }
        }
 // GET: Admin/AppUser
 public ActionResult Index()
 {
     return(View(aurep.GetAll()));
 }
Beispiel #13
0
 private void KullaniciListele()
 {
     dgvKullanici.DataSource = userRep.GetAll();
     dgvKullanici.ClearSelection();
 }
 public ActionResult AddUserDetail()
 {
     ViewBag.Kullanicilar = auRep.GetAll();
     return(View());
 }
Beispiel #15
0
 // GET: Admin/AppUser
 public ActionResult Index()
 {
     // Kullanıcı Listeleme
     return(View(userRepo.GetAll()));
 }