Пример #1
0
    def post(self):
        login_dto = request.get_json()

        user = User.query.filter_by(email=login_dto['email']).first()
        if user is not None and user.check_password(login_dto['password']):
            token = create_access_token(identity=user.id, fresh=True)
            return {'access_token': token}
        else:
            raise InvalidUsage.user_not_found()
Пример #2
0
    def delete(self, request_id):
        request = Request.get_by_id(request_id)
        if request is None:
            raise InvalidUsage.user_not_found()

        db.session.delete(request)
        db.session.commit()

        return request, HTTPStatus.NO_CONTENT
Пример #3
0
    def delete(self, expense_id):
        expense = Expense.get_by_id(expense_id)
        if expense is None:
            raise InvalidUsage.user_not_found()

        db.session.delete(expense)
        db.session.commit()

        return expense, HTTPStatus.NO_CONTENT
Пример #4
0
    def delete(self, user_id):
        if int(user_id) != int(get_jwt_identity()):
            raise InvalidUsage.unauthorized_token()

        user = User.get_by_id(user_id)
        if user is None:
            raise InvalidUsage.user_not_found()

        db.session.delete(user)
        db.session.commit()

        return user, HTTPStatus.NO_CONTENT
Пример #5
0
    def get(self, user_id):
        user = User.get_by_id(user_id)
        if user is None:
            raise InvalidUsage.user_not_found()

        return user