def post(self, tribe, **_): """ POST /users/create """ role = request.json.get("role", UserRoles.USER) tribe_id = tribe.id if tribe is not None else None user = User.create(username=request.json["username"], password=request.json["password"], name=request.json["name"], role=role, tribe_id=tribe_id) return self.format_success(200, {"user": user.dictionary})
def post(self, tribe: Tribe, body: dict, **_): """ POST /users/claim-token Creates a standard user, using authorization from the token provided Also links the user with a tribe obtained from the token. """ del body["token"] user = User.create(tribe_id=tribe.id, role=UserRoles.USER, **body) print(user) access, refresh = generate_jwt_keypair(user.id, tribe.id, user.role) return self.format_success( 200, { "user": user.dictionary, "tokens": { "access": access, "refresh": refresh } })