Esempio n. 1
0
        public async Task <ReceivedUserLoginDTO> LoginUser(GetUserDTO incomingLoginDTO)
        {
            var hashChecker = new VerifyPasswordHashEngine();

            var receivedUser = await _userLoginInvoker.InvokeLoginUserCommand(_mapper.Map <GetUserRAO>(incomingLoginDTO));

            if (hashChecker.VerifyPasswordHash(incomingLoginDTO.Password, receivedUser.PasswordHash, receivedUser.PasswordSalt))
            {
                return(_mapper.Map <ReceivedUserLoginDTO>(receivedUser));
            }
            return(null);
        }
Esempio n. 2
0
        public async Task <ReceivedExistingDTO> LoginUser(GetLoginUserDTO userDTO)
        {
            var rao          = PrepareUserRAOForLogin(userDTO);
            var receivedUser = await _existingUserInvoker.InvokeLoginUserCommand(rao);

            var verifyPasswordHashEngine = new VerifyPasswordHashEngine();

            if (verifyPasswordHashEngine.VerifyPasswordHash(userDTO.Password, receivedUser.PasswordHash, receivedUser.PasswordSalt))
            {
                var receivedUserDTO = _mapper.Map <ReceivedExistingDTO>(receivedUser);
                return(receivedUserDTO);
            }

            return(null);
        }
Esempio n. 3
0
        public async Task <ReceivedExistingUserDTO> LoginUser(QueryForExistingUserDTO userDTO)
        {
            var rao         = _mapper.Map <QueryForExistingUserRAO>(userDTO);
            var queryForRAO = _mapper.Map <QueryForExistingUserRAO>(userDTO);

            var received = await _loginInvoker.InvokeLoginCommand(queryForRAO);

            var verifyPasswordEngine = new VerifyPasswordHashEngine();
            var passwordsMatch       = verifyPasswordEngine.VerifyPasswordHash(userDTO.Password, received.PasswordHash, received.PasswordSalt);

            if (passwordsMatch)
            {
                return(_mapper.Map <ReceivedExistingUserDTO>(received));
            }
            else
            {
                throw new Exception("Passwords do not match!");
            }
        }