mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* 🚪 fix: Let Concurrent First OpenID Logins Continue as the New User Two requests for the same not-yet-created OpenID identity both missed findOpenIDUser and both called createUser; the unique email and OpenID indexes rejected the second insert, and that login failed with E11000. createUserIfAbsent (data-schemas) inserts a first-login user and reports a lost race as { ok: false, error: { code: 'user_exists' } }. It initializes the start balance under the new user's id before inserting the user, so the account is never visible without it, and removes that balance when the write fails or a unique index rejects the insert. createUser shares the insert-only credit (creditStartBalance). createOpenIDUser (packages/api) creates through it and, on user_exists, repeats findOpenIDUser with its provider and issuer checks and continues as the account that won, admitted and refreshed exactly as if the first lookup had found it: the account's own config (tenant config for a tenant account) and its email-domain policy apply, and applyOpenIDProfile writes this callback's claims. It continues only once the winner finished provisioning the account: when that config sets a start balance, the balance must exist, which a previous-release creator credits only after its insert. UserRecord and NewUserData are the plain, storage-neutral contracts. Related to #16766 * ↩️ fix: Hold a Recovered Login on the Creation Config's Start Balance The provisioning barrier read the recovered account's tenant config. With a tenant start balance the base config does not set, every concurrent first login in that tenant failed again, because the winner creates the user under the base config and login balance sync only initializes the tenant balance afterwards. The barrier guards against a previous-release creator's $inc landing on a balance login balance sync already initialized, and that creator only credits the base config's start balance. createOpenIDUser now holds the recovered login only when the config new users are created under sets a start balance; a tenant-only start balance is initialized insert-only by login balance sync and cannot be added twice. |
||
|---|---|---|
| .. | ||
| app | ||
| cache | ||
| config | ||
| db | ||
| models | ||
| server | ||
| strategies | ||
| test | ||
| utils | ||
| jest.config.js | ||
| jsconfig.json | ||
| package.json | ||
| typedefs.js | ||