diff --git a/backend/endpoints/user.py b/backend/endpoints/user.py index 70558969d..d0549e2ab 100644 --- a/backend/endpoints/user.py +++ b/backend/endpoints/user.py @@ -109,14 +109,14 @@ def add_user( status_code=status.HTTP_201_CREATED, ) def create_invite_link( - request: Request, role: str, expiration_seconds: int | None = None + request: Request, role: str, expiration: int | None = None ) -> InviteLinkSchema: """Create an invite link for a user. Args: request (Request): FastAPI Request object role (str): The role of the user - expiration_seconds (int | None): Token expiration in seconds. Defaults to + expiration (int | None): Token expiration in seconds. Defaults to the INVITE_TOKEN_EXPIRY_SECONDS environment variable. Returns: @@ -140,8 +140,8 @@ def create_invite_link( detail=msg, ) - if expiration_seconds is not None and expiration_seconds <= 0: - msg = "expiration_seconds must be a positive integer" + if expiration is not None and expiration <= 0: + msg = "expiration must be a positive integer" log.error(msg) raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, @@ -149,7 +149,7 @@ def create_invite_link( ) token = auth_handler.generate_invite_link_token( - request.user, role=role, expiration_seconds=expiration_seconds + request.user, role=role, expiration=expiration ) return InviteLinkSchema.model_validate({"token": token}) diff --git a/backend/handler/auth/base_handler.py b/backend/handler/auth/base_handler.py index e895853ff..0c2b1c460 100644 --- a/backend/handler/auth/base_handler.py +++ b/backend/handler/auth/base_handler.py @@ -170,19 +170,21 @@ class AuthHandler: await RedisSessionMiddleware.clear_user_sessions(user.username) def generate_invite_link_token( - self, user: Any, role: str, expiration_seconds: int | None = None + self, user: Any, role: str, expiration: int | None = None ) -> str: """ Generate an invite link token for the user. Args: user (Any): The user object. role (str): The role of the user. - expiration_seconds (int | None): Token expiration in seconds. Defaults to + expiration (int | None): Token expiration in seconds. Defaults to the INVITE_TOKEN_EXPIRY_SECONDS environment variable. Returns: str: The generated invite link token. """ - expires_in = expiration_seconds if expiration_seconds is not None else INVITE_TOKEN_EXPIRY_SECONDS + expires_in = ( + expiration if expiration is not None else INVITE_TOKEN_EXPIRY_SECONDS + ) now = datetime.now(timezone.utc) jti = str(uuid.uuid4()) diff --git a/frontend/src/components/Settings/Administration/Users/Dialog/InviteLink.vue b/frontend/src/components/Settings/Administration/Users/Dialog/InviteLink.vue index 1a09d98b3..756d0c593 100644 --- a/frontend/src/components/Settings/Administration/Users/Dialog/InviteLink.vue +++ b/frontend/src/components/Settings/Administration/Users/Dialog/InviteLink.vue @@ -31,7 +31,7 @@ function createInviteLink() { userApi .createInviteLink({ role: selectedRole.value, - expirationSeconds: selectedExpiration.value, + expiration: selectedExpiration.value, }) .then(({ data }) => { emitter?.emit("snackbarShow", { diff --git a/frontend/src/services/api/user.ts b/frontend/src/services/api/user.ts index db563b610..ed338d52e 100644 --- a/frontend/src/services/api/user.ts +++ b/frontend/src/services/api/user.ts @@ -26,14 +26,14 @@ async function createUser({ async function createInviteLink({ role, - expirationSeconds, + expiration, }: { role: string; - expirationSeconds?: number; + expiration?: number; }) { const params: Record = { role }; - if (expirationSeconds !== undefined) { - params.expiration_seconds = expirationSeconds; + if (expiration !== undefined) { + params.expiration = expiration; } return api.post("/users/invite-link", {}, { params }); }