예제 #1
0
class UserV1CollectionResource(Resource):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.adaptor = UserAdaptor(current_repo)

    def get(self):
        """
        사용자 목록
        ---
        tags:
        - users
        responses:
          200:
            description: "Success"
        """

        users = self.adaptor.get_list()
        return users

    def post(self):
        """
        사용자 생성
        ---
        tags:
        - users
        responses:
          200:
            description: "Success"
        """
        email = request.json.get("email")
        password = request.json.get("password")

        user = self.adaptor.create(
            UserInputData(email=email, password=password))
        return user
예제 #2
0
class CurrentUserV1Resource(Resource):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.adaptor = UserAdaptor(current_repo)

    def get(self):
        """
        현재 세션의 사용자 정보
        ---
        tags:
        - users
        responses:
          200:
            description: "Success"
        """
        user_id = request.headers["USER-ID"]
        user = self.adaptor.get(user_id)
        return user

    def put(self):
        """
        현재 세션의 사용자 정보 수정
        ---
        tags:
        - users
        responses:
          200:
            description: "Success"
        """
        user_id = request.headers["USER-ID"]
        email = request.json.get("email")
        password = request.json.get("password")
        user = self.adaptor.update(
            user_id, UserInputData(email=email, password=password))
        return user
예제 #3
0
class UserV1Resource(Resource):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.adaptor = UserAdaptor(current_repo)

    def get(self, id: int):
        """
        개별 사용자 정보
        ---
        tags:
        - users
        responses:
          200:
            description: "Success"
        """
        user = self.adaptor.get(id)

        return user
예제 #4
0
class UserAuthenticateV1Resource(Resource):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.adaptor = UserAdaptor(current_repo)

    def post(self):
        """
        사용자 인증
        email 과 password 를 통한 사용자 인증
        ---
        tags:
        - users
        responses:
          200:
            description: "Success"
        """
        email = request.json.get("email")
        password = request.json.get("password")
        user = self.adaptor.authenticate(email=email, password=password)

        return user
예제 #5
0
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.adaptor = UserAdaptor(current_repo)