Skip to content

feat: support a default expiry for organisation invite links#7869

Open
cloorc wants to merge 1 commit into
Flagsmith:mainfrom
cloorc:feat/invite-link-default-expiry
Open

feat: support a default expiry for organisation invite links#7869
cloorc wants to merge 1 commit into
Flagsmith:mainfrom
cloorc:feat/invite-link-default-expiry

Conversation

@cloorc

@cloorc cloorc commented Jun 25, 2026

Copy link
Copy Markdown

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

InviteLink.expires_at is nullable and, when left blank, the link never
expires (is_expired returns False while expires_at is None). There is
currently no way for an operator to make invite links expire by default — each
link would have to be created with an explicit expires_at.

This PR adds an opt-in INVITE_LINK_EXPIRY_DAYS setting:

  • When set, a newly created InviteLink without an explicit expires_at
    defaults to now + INVITE_LINK_EXPIRY_DAYS days (applied via a
    BEFORE_CREATE lifecycle hook).
  • The setting defaults to None, preserving today's indefinite behaviour, so
    this is fully backward compatible.
  • An explicitly provided expires_at is never overridden.

How did you test this code?

Added unit tests in test_unit_invites_models.py:

  • …default_expiry_setting__sets_expires_at — with the setting configured, a
    link created without an expiry gets expires_at ≈ now + N days.
  • …no_default_expiry_setting__stays_indefinite — with the setting unset, a
    link created without an expiry stays expires_at = None.
  • …explicit_expiry__not_overridden_by_default — an explicit expires_at is
    preserved even when the setting is configured.

Invite links (InviteLink) never expire unless an explicit expires_at is
provided at creation time, so by default they remain valid indefinitely.
This adds an opt-in INVITE_LINK_EXPIRY_DAYS setting: when configured, a
newly created invite link without an explicit expires_at defaults to
now + INVITE_LINK_EXPIRY_DAYS days.

The setting defaults to None, preserving the existing indefinite behaviour,
and an explicitly provided expires_at is never overridden.

Signed-off-by: Cloorc <wittcnezh@foxmail.com>
@cloorc cloorc requested a review from a team as a code owner June 25, 2026 10:25
@cloorc cloorc requested review from emyller and removed request for a team June 25, 2026 10:25
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@cloorc is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the api Issue related to the REST API label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants