Skip to content

Commit

Permalink
Reduce casing complexity, loop over options registery, endsWith('sock')
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Dec 2, 2020
1 parent 603655f commit 73988a7
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 78 deletions.
17 changes: 17 additions & 0 deletions src/cmap/auth/mongo_credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,24 @@ export class MongoCredentials {
}

if (this.mechanism === AuthMechanism.MONGODB_X509 && this.password != null) {
if (this.password === '') {
Reflect.set(this, 'password', undefined);
return;
}
throw new TypeError(`Password not allowed for mechanism MONGODB-X509`);
}
}

static merge(
creds: MongoCredentials,
options: Partial<MongoCredentialsOptions>
): MongoCredentials {
return new MongoCredentials({
username: options.username ?? creds.username,
password: options.password ?? creds.password,
mechanism: options.mechanism ?? creds.mechanism,
mechanismProperties: options.mechanismProperties ?? creds.mechanismProperties,
source: options.source ?? creds.source ?? options.db
});
}
}
Loading

0 comments on commit 73988a7

Please sign in to comment.