1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: change default admin password

This commit is contained in:
Ivar Conradi Østhus 2021-04-26 11:28:51 +02:00
parent c216181f8e
commit 2874ae71b6
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09

View File

@ -9,7 +9,6 @@ import { Logger } from '../logger';
import User, { IUser } from '../types/user'; import User, { IUser } from '../types/user';
import isEmail from '../util/is-email'; import isEmail from '../util/is-email';
import { AccessService, RoleName } from './access-service'; import { AccessService, RoleName } from './access-service';
import { ADMIN } from '../permissions';
import ResetTokenService from './reset-token-service'; import ResetTokenService from './reset-token-service';
import InvalidTokenError from '../error/invalid-token-error'; import InvalidTokenError from '../error/invalid-token-error';
import NotFoundError from '../error/notfound-error'; import NotFoundError from '../error/notfound-error';
@ -75,14 +74,7 @@ class UserService {
getLogger, getLogger,
authentication, authentication,
}: Pick<IUnleashConfig, 'getLogger' | 'authentication'>, }: Pick<IUnleashConfig, 'getLogger' | 'authentication'>,
{ { accessService, resetTokenService, emailService }: IServices,
accessService,
resetTokenService,
emailService,
}: Pick<
IServices,
'accessService' | 'resetTokenService' | 'emailService'
>,
) { ) {
this.logger = getLogger('service/user-service.js'); this.logger = getLogger('service/user-service.js');
this.store = stores.userStore; this.store = stores.userStore;
@ -107,13 +99,14 @@ class UserService {
if (!hasAdminUser) { if (!hasAdminUser) {
// create default admin user // create default admin user
try { try {
const pwd = 'unleash4all';
this.logger.info( this.logger.info(
'Creating default user "admin" with password "admin"', `Creating default user "admin" with password "${pwd}"`,
); );
const user = await this.store.insert({ const user = await this.store.insert({
username: 'admin', username: 'admin',
}); });
const passwordHash = await bcrypt.hash('admin', saltRounds); const passwordHash = await bcrypt.hash(pwd, saltRounds);
await this.store.setPasswordHash(user.id, passwordHash); await this.store.setPasswordHash(user.id, passwordHash);
const rootRoles = await this.accessService.getRootRoles(); const rootRoles = await this.accessService.getRootRoles();