Skip to main content

upgradeIdent

@webda/auth


Function: upgradeIdent()

upgradeIdent(legacy, IdentModel?, options?): Promise<Ident>

Defined in: packages/auth/src/compat/upgrade.ts:116

Upgrade a v3 ident: create the "<providerUid>:<provider>" record, then delete the v3 one

Idempotent and crash-safe: when the new record already exists (an earlier upgrade stopped before the delete, or a concurrent one won) it is kept as is and only the v3 record is deleted. Field map: _user → owner, _validation → verifiedAt, _lastUsed → lastUsedAt, _failedLogin → _loginAttempts, _lastFailedLogin → _lastLoginAttemptAt (number or date; absent, the count is treated as an expired lock), _lastValidationEmail → _throttle.lastSentAt; email, __profile are kept, __tokens is encrypted into tokens; provider is provider ?? _type ?? key suffix, providerUid the key prefix (normalised for the email provider: v3 kept the email case). Callers run it as system.

Parameters​

legacy​

Ident

a v3 ident (legacy.getLegacyUID() is set)

IdentModel?​

ModelClass<Ident> = ...

ident model of the application

options?​

options

dryRun?​

boolean

run the checks only: nothing is written, the returned ident is not saved

Returns​

Promise<Ident>

the upgraded ident

Throws​

Error when legacy is not a v3 ident (see isLegacyIdent)

Throws​

IdentConflict when the upgraded key exists, or is created concurrently, with another owner: the v3 record is kept for a manual resolution