@@ -70,7 +70,6 @@ export class UserService {
7070 private readonly logger = new Logger ( UserService . name ) ;
7171 private readonly AUTH0_PROVIDER_NAME = 'auth0' ; // Define constant for Auth0 provider name
7272 private legacyBlowfishKey : string ; // Changed: Store the raw Base64 key string directly
73- private readonly defaultPassword : string ;
7473
7574 constructor (
7675 @Inject ( PRISMA_CLIENT )
@@ -107,9 +106,6 @@ export class UserService {
107106 this . legacyBlowfishKey = '' ;
108107 }
109108 }
110- this . defaultPassword = this . configService . get < string > (
111- 'DEFAULT_REGISTRATION_PASS' ,
112- ) ;
113109 }
114110
115111 // --- Core User Methods ---
@@ -617,6 +613,18 @@ export class UserService {
617613 return otp ;
618614 }
619615
616+ // Generates a cryptographically-strong random password consisting of
617+ // alphanumeric characters of the requested length.
618+ private generateRandomPassword ( length : number ) : string {
619+ const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;
620+ const bytes = crypto . randomBytes ( length ) ;
621+ let result = '' ;
622+ for ( let i = 0 ; i < length ; i ++ ) {
623+ result += charset [ bytes [ i ] % charset . length ] ;
624+ }
625+ return result ;
626+ }
627+
620628 /**
621629 * Encodes password using the legacy Blowfish/ECB/PKCS5Padding method.
622630 * Matches the logic from the old Java Utils.encodePassword.
@@ -690,7 +698,8 @@ export class UserService {
690698 userParams . credential = { } as CredentialDto ;
691699 }
692700 if ( ! CommonUtils . validateString ( userParams . credential . password ) ) {
693- userParams . credential . password = this . defaultPassword ;
701+ // Generate a unique random password for social/SSO registrations
702+ userParams . credential . password = this . generateRandomPassword ( 16 ) ;
694703 }
695704 }
696705 // perform initial static validations
0 commit comments