def profile_view(user): """ Retrieves basic user information """ controller = UserController(user_id=user.id) return jsonify({ 'user': controller.get_user().to_dict(include_protected=True, replace_id=True) })
def edit_view(user): """ Retrieves basic user information """ controller = UserController(user_id=user.id) try: controller.update_user(request.get_json()) except UserControllerException as exc: LOGGER.error('Could not update user', **exc.errors) response = jsonify({ 'message': 'User update failed', 'errors': exc.errors }) response.status_code = 400 return response return jsonify({ 'user': controller.get_user().to_dict(include_protected=True, replace_id=True) })
def get_user(id): user = UserController.get_user(id) return (dict(user=user))
async def get_user(request: Request, jwt_token: JwtToken = Depends(verify_token)): user_controller = UserController(request=request) return user_controller.get_user(user_id=jwt_token.user_id)