BookStackApp/BookStack · error · UserRegistrationException

errors.error_user_exists_different_creds

Error message

errors.error_user_exists_different_creds

What it means

UserRegistrationException thrown during social registration callback when no social account matches but a BookStack user with the same email address already exists. Registration with the social identity would create a duplicate account, so the flow aborts with errors.error_user_exists_different_creds, telling the user that email is registered with different credentials.

Source

Thrown at app/Access/SocialAuthService.php:66

        return $this->getDriverForRedirect($socialDriver)->redirect();
    }

    /**
     * Handle the social registration process on callback.
     *
     * @throws UserRegistrationException
     */
    public function handleRegistrationCallback(string $socialDriver, SocialUser $socialUser): SocialUser
    {
        // Check social account has not already been used
        if (SocialAccount::query()->where('driver_id', '=', $socialUser->getId())->exists()) {
            throw new UserRegistrationException(trans('errors.social_account_in_use', ['socialAccount' => $socialDriver]), '/login');
        }

        if (User::query()->where('email', '=', $socialUser->getEmail())->exists()) {
            $email = $socialUser->getEmail();

            throw new UserRegistrationException(trans('errors.error_user_exists_different_creds', ['email' => $email]), '/login');
        }

        return $socialUser;
    }

    /**
     * Get the social user details via the social driver.
     *
     * @throws SocialDriverNotConfigured
     */
    public function getSocialUser(string $socialDriver): SocialUser
    {
        $socialDriver = trim(strtolower($socialDriver));
        $this->driverManager->ensureDriverActive($socialDriver);

        return $this->socialite->driver($socialDriver)->user();
    }

View on GitHub (pinned to 18f8469a1c)

Solutions

  1. Log in with the original credentials (email/password) instead of registering via the social provider
  2. Once logged in, attach the social account to the existing user via profile 'External authentication' / social connector settings
  3. Use password reset if the original password is forgotten, then link the social account
  4. Admin can verify/merge accounts in the users admin section
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check email collision before the registration callback
$emailTaken = \BookStack\Users\User::query()
    ->where('email', '=', $socialUser->getEmail())
    ->exists();
if ($emailTaken) {
    return redirect('/login')->with('info', 'An account with this email already exists. Log in and link the social account from your profile.');
}

Try / catch

use BookStack\Exceptions\UserRegistrationException;

try {
    $socialUser = $socialAuth->handleRegistrationCallback($driver, $socialUser);
} catch (UserRegistrationException $e) {
    if (str_contains($e->getMessage(), trans('errors.error_user_exists_different_creds', ['email' => $socialUser->getEmail()]))) {
        return redirect('/login')->with('info', 'Email already registered with another method — please log in and link your account.');
    }
    throw $e;
}

Prevention

When it happens

Trigger: User attempts /register/service/<driver> with a social account whose email equals the email of an existing BookStack user that was created via email/password (or a different auth method), and no social_accounts row exists for this driver_id.

Common situations: User registered earlier with email+password then tries to sign up via Google/GitHub using the same address; admin pre-created the user with the same email; email changed at the IdP to collide with an existing local account.

Related errors


AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02). Data as JSON: /api/errors/6b37ca5119704de8. Report an issue: GitHub.