def process_request(self, request):
     auth_header = request.META.get('HTTP_AUTHORIZATION', '')
     if auth_header.startswith('PDB'):
         token = auth_header[4:]
         user_service = UserService()
         user = user_service.get_user_by_auth_token(token)
         if user is not None:
             request.pdbuser = user
         else:
             request.pdbuser = None
Exemple #2
0
 def __init__(self, auth_service=None, user_service=None, *args, **kwargs):
     if auth_service is None:
         self.__auth_service = AuthService()
     else:
         self.__auth_service = auth_service
     if user_service is None:
         self.__user_service = UserService()
     else:
         self.__user_service = user_service
     super(UserViewSet, self).__init__(UserJsonSerializer(), *args,
                                       **kwargs)
    def __init__(self,
                 exercise_evaluation_query_repository=None,
                 exercise_evaluation_command_repository=None,
                 user_service=None):
        if exercise_evaluation_query_repository is not None:
            self.__exercise_evaluation_query_repository = exercise_evaluation_query_repository
        else:
            exercise_evaluation_query_repository_factory = ExerciseEvaluationQueryRepositoryFactory(
            )
            self.__exercise_evaluation_query_repository = exercise_evaluation_query_repository_factory.create_exercise_evaluation_query_repository(
            )

        if exercise_evaluation_command_repository is not None:
            self.__exercise_evaluation_command_repository = exercise_evaluation_command_repository
        else:
            exercise_evaluation_command_repository_factory = ExerciseEvaluationCommandRepositoryFactory(
            )
            self.__exercise_evaluation_command_repository = exercise_evaluation_command_repository_factory.create_exercise_evaluation_command_repository(
            )

        if user_service is not None:
            self.__user_service = user_service
        else:
            self.__user_service = UserService()
Exemple #4
0
 def setUp(self):
     self.stub_user_query_repository = mock.Mock(spec=IUserQueryRepository)
     self.stub_user_command_repository = mock.Mock(spec=IUserCommandRepository)
     self.sut = UserService(self.stub_user_query_repository, self.stub_user_command_repository)