예제 #1
0
        /// <summary>
        /// Method to autorization
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task <string> GetUser(LoginRequest query)
        {
            var user = await _queryrepository.GetUser(query.UserName)
                       ?? throw new UserNotExistsException();

            var password = _signInManager.GetPassword(query.Password, user.Salt);

            if (user.Password != password)
            {
                throw new UserNotExistsException();
            }
            return(_signInManager.GenerateToken(query.UserName, user.Id.ToString()));
        }
예제 #2
0
        public async Task <string> HandleAsync(SignInQuery query)
        {
            var user = await _repository.FindUserByUserName(query.UserName)
                       ?? throw new UserNotFoundException();

            var password = _signInManager.GetPassword(query.Password, user.Salt);

            if (user.Password != password)
            {
                throw new UserNotFoundException();
            }

            return(_signInManager.GenerateToken());
        }