OIDC/SSO flow drops invite code context (multi-community auto-join issue)

(#4737) Bug Open: Awaiting confirmation desktop self-hosting

Reproduction steps

  1. Set up a self-hosted instance with SSO (OIDC) enabled.
  2. Keep "Single community" mode disabled (multi-guild setup).
  3. Create an invite link for a guild (e.g. /invite/XYZ).
  4. As an unauthenticated visitor, navigate to https://fluxer.example.com/invite/XYZ.
  5. Click to log in / sign up via SSO (OIDC redirect flow).
  6. Complete authorization at the IdP and return to Fluxer.

Expected behaviour

Upon completing SSO, the user should automatically join the specific guild from the invite link they opened (/invite/XYZ).

Actual behaviour

The invite code from the URL is dropped during the SSO redirect flow. The backend only attempts to join the static FLUXER_AUTO_JOIN_INVITE_CODE from the .env. If that env code is missing/stale, the user joins nothing (404 UNKNOWN_INVITE in logs) and lands on an empty dashboard, requiring a second click on the invite link. If multiple guilds exist, the user joins the wrong static guild instead of the one they were invited to.

Build information

Self-hosted Docker (Linux arm64) API image: ghcr.io/fluxerapp/fluxer-api (digest: 57ab0af50711) Frontend: ghcr.io/fluxerapp/fluxer-app-proxy-self-hosted (digest: 775dcc3bdc94) Version: v1 / 2026.1026

Platform

Web, API, Self-hosting

Evidence

fluxer-api log showing maybeAutoJoinInvite strictly bound to the static env code during SSO callback: {"level":"warn","service":"fluxer-api","inviteCode":"<STATIC_ENV_CODE>","msg":"Failed to auto-join invite","error":{"type":"UnknownInviteError","message":"UNKNOWN_INVITE","stack":"FluxerError: UNKNOWN_INVITE\n at InviteService.acceptInvite\n at async maybeAutoJoinInvite (chunk-SJ7ZDF6P.js:23255:7)\n at async _SsoService.resolveUserFromClaims (chunk-SJ7ZDF6P.js:28120:5)"}}
  1. The pull request fluxer#3983 mentions this post Merged
  2. The pull request fluxer#3983 was merged Merged
  3. The pull request fluxer#3984 mentions this post Merged

3 comments

Sign in with Fluxer to comment and vote.
Comment by Rex
RexSystem 1 vote
Status changed from Needs triage to Awaiting confirmation
Fixed thanks to CyberPingU. Signing up with SSO now joins the community from the invite link you opened, and also your auto-join community if you have one set. If one of the two invites is invalid, the other one still works. It's in self-hosted release 2026.1113.53223. Could you update and let us know if it works for you?
Comment by errno0x0d
errno0x0d OP1 vote
Implementation suggestion to easily fix this:
  1. In the client apps (Web, Desktop, Mobile): When an unauthenticated visitor clicks "Login with SSO" on an /invite/:code landing screen, ensure POST /v1/auth/sso/start includes redirect_to: window.location.pathname (or an explicit invite_code parameter) so it gets preserved in the OAuth statePayload.
  1. In SsoService (completeLogin / resolveUserFromClaims): Extract the invite code from statePayload.redirectTo if it matches /invite/:code and prioritize it:
const inviteMatch = statePayload.redirectTo?.match(/\/invite\/([a-zA-Z0-9_-]+)/);
const inviteCodeToJoin = inviteMatch ? inviteMatch[1] : autoJoinInviteCode;

if (inviteCodeToJoin) {
  await maybeAutoJoinInvite(this.inviteService, {
    userId: user.id,
    inviteCode: inviteCodeToJoin,
    requestCache
  });
}
This ensures the user seamlessly lands inside the specific invited guild across all platforms, while preserving the static FLUXER_AUTO_JOIN_INVITE_CODE fallback for generic root signups.
Comment by errno0x0d
errno0x0d OP1 vote
After inspecting the codebase, the fix is even simpler than expected because the client and OAuth state handling are already doing their job!
  1. AuthLoginLayout.tsx already passes redirect_to: ssoRedirectPath (e.g. /invite/<code_b>) to POST /v1/auth/sso/start.
  2. startSso preserves it in statePayload.redirectTo.
  3. completeLogin in SsoService.ts already retrieves const redirectTo = statePayload.redirectTo ?? ''.
The only missing link is that resolveUserFromClaims does not receive redirectTo, so it only falls back to config.instance.autoJoinInviteCode.

Suggested fix in SsoService.ts & SsoUtils.ts:

  1. In SsoUtils.ts:
    export function extractInviteCodeFromRedirect(redirectTo?: string): string | null {
      const sanitized = sanitizeSsoRedirectTo(redirectTo);
      if (!sanitized) return null;
      const match = sanitized.match(/^\/invite\/([a-zA-Z0-9_-]+)(?:[?#]|$)/);
      return match ? match[1] : null;
    }
  1. In SsoService.ts:
Pass redirectTo into resolveUserFromClaims(..., redirectTo) and resolve the effective invite code matching the GuildEntry.ts pattern (inviteCode || autoJoinInviteCode):
const inviteCodeFromRedirect = extractInviteCodeFromRedirect(redirectTo);
const autoJoinInviteCode =
  inviteCodeFromRedirect || this.apiContext.services.config.instance.autoJoinInviteCode?.trim() || null;
This guarantees that:
  • Visitors arriving via a specific /invite/<code_b> link auto-join that specific guild upon SSO completion.
  • Generic visitors without an invite link still fall back to FLUXER_AUTO_JOIN_INVITE_CODE.