fix: Indexes _email_verify_token for email verification and _perishable_token password reset are not created automatically (#9893)
This commit is contained in:
@@ -687,6 +687,7 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
const defaultOptions: Object = { background: true, sparse: true };
|
||||
const indexNameOptions: Object = indexName ? { name: indexName } : {};
|
||||
const ttlOptions: Object = options.ttl !== undefined ? { expireAfterSeconds: options.ttl } : {};
|
||||
const sparseOptions: Object = options.sparse !== undefined ? { sparse: options.sparse } : {};
|
||||
const caseInsensitiveOptions: Object = caseInsensitive
|
||||
? { collation: MongoCollection.caseInsensitiveCollation() }
|
||||
: {};
|
||||
@@ -695,6 +696,7 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
...caseInsensitiveOptions,
|
||||
...indexNameOptions,
|
||||
...ttlOptions,
|
||||
...sparseOptions,
|
||||
};
|
||||
|
||||
return this._adaptiveCollection(className)
|
||||
|
||||
@@ -1764,6 +1764,20 @@ class DatabaseController {
|
||||
throw error;
|
||||
});
|
||||
|
||||
await this.adapter
|
||||
.ensureIndex('_User', requiredUserFields, ['_email_verify_token'], '_email_verify_token', false)
|
||||
.catch(error => {
|
||||
logger.warn('Unable to create index for email verification token: ', error);
|
||||
throw error;
|
||||
});
|
||||
|
||||
await this.adapter
|
||||
.ensureIndex('_User', requiredUserFields, ['_perishable_token'], '_perishable_token', false)
|
||||
.catch(error => {
|
||||
logger.warn('Unable to create index for password reset token: ', error);
|
||||
throw error;
|
||||
});
|
||||
|
||||
await this.adapter.ensureUniqueness('_Role', requiredRoleFields, ['name']).catch(error => {
|
||||
logger.warn('Unable to ensure uniqueness for role name: ', error);
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user