Skip to content

Conversation

@kaumudpa
Copy link

Title

feat(auth): add unified email accounts - optional account linking across providers


What kind of change does this PR introduce?

Feature - Adds opt-in unified email accounts that allow users to access their account through any authentication provider (OAuth or email/password) using the same email address.

Why was this change needed?

Currently, Postiz treats each provider + email combination as a separate account. This creates friction for users:

  1. User registered with email/password, later tries Google OAuth: Gets redirected to sign-up page instead of logging in, even though the email is the same
  2. Self-hosted instances with registration disabled: OAuth users with matching emails cannot access their existing accounts
  3. User flexibility: Users may want to use OAuth on mobile but password on shared computers

This PR introduces a new UNIFIED_EMAIL_ACCOUNTS environment variable (default: false) that when enabled:

  • Allows OAuth login to find and use existing email/password accounts
  • Allows email/password registration to add a password to existing OAuth accounts (with email verification for security)
  • Enables forgot password for any account with a password set

Security: When an OAuth user adds a password, email verification is required to prevent account hijacking.

Backward compatibility: When the flag is disabled (default), all existing behavior is 100% preserved.

Fixes #1120

Other information:

Files changed:

  • auth.service.ts - Core logic with flag checks
  • auth.controller.ts - Simplified to use service response
  • users.repository.ts - Added getUserByEmailAnyProvider(), setPassword(), setPasswordHash()
  • users.service.ts - Exposed new repository methods
  • .env.example - Documented new variable

New environment variable:

UNIFIED_EMAIL_ACCOUNTS=true  # Default: false (disabled)

This feature is useful for self-hosted instances that want a single account per email across multiple auth providers.

Checklist:

Put a "X" in the boxes below to indicate you have followed the checklist;

  • I have read the CONTRIBUTING guide.
  • I checked that there were not similar issues or PRs already open for this.
  • This PR fixes just ONE issue (do not include multiple issues or types of change in the same PR) For example, don't try and fix a UI issue and include new dependencies in the same PR.

@vercel
Copy link

vercel bot commented Dec 15, 2025

@kaumudpa is attempting to deploy a commit to the Listinai Team on Vercel.

A member of the Team first needs to authorize it.

@kaumudpa kaumudpa marked this pull request as draft December 15, 2025 21:40
@kaumudpa kaumudpa marked this pull request as ready for review December 15, 2025 21:52
@kaumudpa kaumudpa marked this pull request as draft December 15, 2025 21:59
@kaumudpa kaumudpa marked this pull request as ready for review December 15, 2025 22:12
Unify account handling so OAuth users and local users share the same email
record. When a user signs up with OAuth, if their email already exists as
a local account, the accounts are linked. This allows users to:
- Sign in with either OAuth or local credentials
- Have a single user profile regardless of auth method

Includes null checks and proper user object handling for JWT activation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unified Email Accounts - Allow same email across OAuth and Local providers

1 participant