Verify the invitation to join a project for a guest user
Note that a guest user would not be allowed to do this themselves.
Source code in fractal_server/app/routes/admin/v2/sharing.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150 | @router.post("/verify/", status_code=200)
async def verify_invitation_for_guest(
guest_user_id: int,
project_id: int,
superuser: UserOAuth = Depends(current_superuser_act),
db: AsyncSession = Depends(get_async_db),
) -> None:
"""
Verify the invitation to join a project for a guest user
Note that a guest user would not be allowed to do this themselves.
"""
# Get user and verify that they actually are a guest
guest_user = await _user_or_404(guest_user_id, db)
if not guest_user.is_guest:
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail="Cannot accept invitations for non-guest users.",
)
# Find verification and check that permissions are set to R
link = await get_pending_invitation_or_404(
user_id=guest_user_id, project_id=project_id, db=db
)
if link.permissions != ProjectPermissions.READ:
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=(
"Guest users can only have 'r' permission "
f"(given: '{link.permissions}')"
),
)
# Mark the invitation as verified
link.is_verified = True
await db.commit()
return Response(status_code=status.HTTP_200_OK)
|