Skip to content

Commit 8b0a526

Browse files
committed
create more secure random PWs for DB
1 parent ad1cbb2 commit 8b0a526

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/users/ldap/ldapusers.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Logger } from '@nestjs/common';
1010
import { Entry as LdapEntry, Client as LdapClient } from 'ldapts';
1111
import { Users } from '../users.interface';
1212
import { ConfigService } from '@nestjs/config';
13+
import { genSaltSync } from 'bcryptjs';
1314

1415
type LDAPConfig = {
1516
url: string;
@@ -91,7 +92,7 @@ export class LdapUsersService implements Users {
9192
firstName: ldapEntry[this.ldapConfig.attributeFirstName].toString(),
9293
lastName: ldapEntry[this.ldapConfig.attributeLastName].toString(),
9394
apiKey: this.authService.generateApiKey(),
94-
password: await this.authService.encryptPassword(Math.random().toString(36).slice(-8)),
95+
password: await this.authService.encryptPassword(genSaltSync(1).slice(-12)),
9596
role: Role.editor,
9697
};
9798

0 commit comments

Comments
 (0)