public OperationResult LogIn(string login, string password) { var user = _repository.FindByPredicate <User>(x => x.Login == login) ?? throw new AuthorizationException( "User with such login does not exist. Please review your credentials.", nameof(login)); if (!_checkerService.Check(user.Password, password)) { throw new AuthorizationException("Invalid password. Please review your credentials.", nameof(password)); } return(new OperationResult() { Success = true, Data = new JwtSecurityTokenHandler().WriteToken(_tokenService.GenerateToken(user)) }); }