/// <summary>
        ///  Viewing all users type U
        ///  shows only username, email and type of user
        /// </summary>
        /// <param name="userInformations"></param>
        /// <returns></returns>
        public DataTable viewAllUsers(UserInformations userInformations)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "spSelectAllUsersU";
            return(db.ExeReader(cmd));
        }
Example #2
0
        public async Task <IActionResult> LoginLdap([FromBody] LoginModel body)
        {
            if (await _emailService.GetCaptchaNotPassed(body.Captcha))
            {
                return(ErrorResponse($"Prvok Re-Captcha je zlý skúste znova."));
            }

            if (body.Email.Contains('@'))
            {
                return(ErrorResponse($"Meno nie je správne, použite študentské meno, nie email."));
            }
            _logger.LogInformation($"Request init from ldap.");
            UserInformations ldapInformations = null;

            try
            {
                ldapInformations = _userService.GetUserFromLDAP(body.Email, body.Password, _logger);
            } catch (LdapException e)
            {
                _logger.LogError($"Exception while logging into ldap: {e}");
                return(ErrorResponse(e.ResultCode == 49 ? $"Meno alebo heslo nie je správne, skúste znova prosím." : $"Prepáčte, niečo na serveri nie je v poriadku, skúste neskôr prosím.")); //49 = InvalidCredentials
            }
            _logger.LogInformation($"Response received from ldap.");
            body.Password = _userService.GetDefaultLdapPassword();

            if (ldapInformations == null)
            {
                _logger.LogInformation($"Invalid ldap login attemp. User {body.Email} doesn't exist.");
                return(ErrorResponse($"Meno alebo heslo nie je správne, skúste znova prosím."));
            }
            ldapInformations.Email = ldapInformations.Email.ToLower();
            User user = await _userService.GetUserByEmailAsync(ldapInformations.Email);

            if (user == null)
            {
                if (!_userService.AddLdapUser(ldapInformations).Result)
                {
                    _logger.LogInformation($"Invalid ldap login attemp. User with email {body.Email} already exists.");
                    return(ErrorResponse($"Váš študentský email s koncovkou " + ldapInformations.Email.Split('@')[1] + " je už zaregistrovaný."));
                }
                user = await _userService.GetUserByEmailAsync(ldapInformations.Email);

                _userService.TryAddStudent(user);
                AuthenticatedUserModel auth = new AuthenticatedUserModel(user, _userService.GenerateJwtToken(ldapInformations.Email))
                {
                    FirstTimePN = ldapInformations.PersonalNumber
                };
                return(Ok(auth));
            }
            else
            {
                _userService.TryAddStudent(user);
                AuthenticatedUserModel auth = new AuthenticatedUserModel(user, _userService.GenerateJwtToken(ldapInformations.Email));
                return(Ok(auth));
            }
        }
        /// <summary>
        /// Login user using the parameters
        /// </summary>
        /// <param name="userInfoinfo"></param>
        /// <returns></returns>

        public DataTable loginUser(UserInformations userInfo)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "spGetuserNameWithPassword";
            cmd.Parameters.AddWithValue("@userName", userInfo.userName);
            cmd.Parameters.AddWithValue("@password", userInfo.password);

            return(db.ExeReader(cmd)); //Better to use Scalar
        }
        /// <summary>
        /// Inserting value to databse
        /// We use stored procedure that is in sql server
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public int insertNewUserData(UserInformations userInfo)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure; // StoredProcedure is on the SQL Server
            cmd.CommandText = "spRegisterUserDefaultU";
            cmd.Parameters.AddWithValue("@email", userInfo.email);
            cmd.Parameters.AddWithValue("@password", userInfo.password);
            cmd.Parameters.AddWithValue("@userName", userInfo.userName);
            return(db.ExeNonQuery(cmd));
        }
Example #5
0
        public void CallConnectToServer()
        {
            UsersContainer userContainer = FindObjectOfType <UsersContainer>();

            //Checks if the choosen account exists
            UserInformations u = userContainer.GetUserByUsernameAndPassword(InputUsername.Text.Value,
                                                                            InputPass.Text.Value);

            //If the account exists login in into the game scene
            if (!ReferenceEquals(u, null))
            {
                SceneManager.LoadScene(GPCSceneManager.GetSceneIndex(GPCSceneManager.GPCSceneEnum.GAME_SCENE));
            }
            else
            {
                GenericPopUp.ShowPopUp(UIInfoLayer.AccountNotFoundMessage);
            }
        }
        private async Task LoadUsersAsync()
        {
            Users = await _userManager.Users.OrderBy(p => p.DeletedMark).ToListAsync();

            UserPackage = new List <UserInformations>();
            foreach (var user in Users)
            {
                var userInformation = new UserInformations
                {
                    User                = user,
                    ExpressPostCount    = (await _takeExpressService.GetAllActiveMissionByPostUserAsync(user)).Count,
                    PurchasePostCount   = (await _purchaseService.GetAllActiveMissionByPostUserAsync(user)).Count,
                    FleaMarketPostCount = (await _fleaMarketService.GetAllActiveMissionByPostUserAsync(user)).Count,
                    HireMarketPostCount = (await _hireService.GetAllActiveMissionByPostUserAsync(user)).Count,
                };
                UserPackage.Add(userInformation);
            }
        }
Example #7
0
        public async Task <UserInformations> Get(string login)
        {
            var user = await userRepository.GetUser(login);

            if (user == null)
            {
                throw new NotFoundException($"user with login: '******' does't exist.");
            }
            var userResponse = new UserInformations()
            {
                UserId    = user.UserId,
                Login     = user.Login,
                Email     = user.Email,
                CreatedAt = user.CreatedAt,
                Orders    = user.Orders
            };

            return(userResponse);
        }
Example #8
0
    IEnumerator GetUserInfos()
    {
        using (UnityWebRequest www = UnityWebRequest.Get("https://api.gustave.pro/user/infos"))
        {
            www.SetRequestHeader("Authorization", "Bearer " + UserTokens.tokens.access_token);
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
                Debug.Log(www.downloadHandler.text);
            }
            else
            {
                Debug.Log("Form upload complete! UserInfos");
                Debug.Log(www.downloadHandler.text);
                userInformations = getUserInformationsFromJson(www.downloadHandler.text);
                StartCoroutine(UserRecipe());
            }
        }
    }
Example #9
0
        public async Task <IActionResult> DeleteUser([FromBody] DeleteUserModel body)
        {
            body.Email = body.Email.ToLower();
            var user = await _userService.GetUserByEmailAsync(body.Email);

            if (user == null)
            {
                _logger.LogInformation($"Invalid user delete attemp. User {body.Email} doesn't exist.");
                return(ErrorResponse($"Používateľ {body.Email} neexistuje."));
            }

            if (user.IsLdapUser)
            {
                UserInformations ldapInfo = _userService.GetUserFromLDAP(body.Email.Split('@')[0], body.Password, _logger);
                if (ldapInfo == null)
                {
                    _logger.LogWarning($"Invalid login attemp. User {body.Email} entered wrong password.");
                    return(ErrorResponse("Zadané heslo nie je správne."));
                }
            }
            else
            {
                var token = await _userService.Authenticate(body.Email, body.Password);

                if (token == null)
                {
                    _logger.LogWarning($"Invalid login attemp. User {body.Email} entered wrong password.");
                    return(ErrorResponse("Zadané heslo nie je správne."));
                }
            }

            var deleteResult = await _userService.DeleteUserAsyc(user);

            if (deleteResult.Succeeded)
            {
                _logger.LogInformation($"User {body.Email} deleted.");
            }

            return(Ok());
        }
Example #10
0
        public static void Init(TestContext context)
        {
            ConfigurationManager config = ConfigurationManager.Instance.AddBaseUrl("http://*****:*****@test.com",
            };

            _testUserInformation = new UserInformations
            {
                Key   = "dana",
                Value = "petog"
            };
        }
        public async Task <ActionResult> Create(int?offerId)
        {
            if (offerId is null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            JobOffer offer = await dataContext.JobOffers.FindAsync(offerId.Value);

            if (offer == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            return(View(new JobApplicationWithOfferName()
            {
                JobOfferId = offerId.Value,
                OfferName = offer.JobTitle,
                FirstName = UserInformations.GetUserGivenName(User),
                Lastname = UserInformations.GetUserSurname(User),
                EmailAddress = UserInformations.GetUserEmail(User)
            }));
        }
 public void setUserInfo(UserInformations info)
 {
     Debug.Log("SET USR INFO");
     usrInfo = info;
 }