Skip to content

Commit ca18cf7

Browse files
committed
create password based on a secret
1 parent 1d17e81 commit ca18cf7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

server/src/database/database.service.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,20 @@ export class DatabaseService {
126126
const userGroups = ['everyone', 'admin'];
127127

128128
try {
129-
// Generiere ein zufälliges Passwort
130-
const plainPassword = crypto
131-
.randomBytes(25)
132-
.toString('base64')
133-
.slice(0, 19);
134-
// Erstelle einen bcrypt-Hash
129+
let plainPassword: string;
130+
131+
if (!process.env.KUBERO_ADMIN_PASSWORD && process.env.KUBERO_ADMIN_PASSWORD !== '') {
132+
// Generate a random password
133+
plainPassword = crypto
134+
.randomBytes(25)
135+
.toString('base64')
136+
.slice(0, 19);
137+
138+
} else {
139+
plainPassword = process.env.KUBERO_ADMIN_PASSWORD;
140+
}
141+
142+
// create bcrypt hash
135143
const passwordHash = await bcrypt.hash(plainPassword, 10);
136144
console.log('\n\n\n', 'Admin account created since no user exists yet');
137145
console.log(' username: ', adminUser);

0 commit comments

Comments
 (0)