1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Removing default enforced admin/admin user, only adding it if no admin is present. fixes #408

This commit is contained in:
Patrik J. Braun 2022-01-20 19:45:25 +01:00
parent a4a9fe2c98
commit b169fa67b3
2 changed files with 12 additions and 2 deletions

View File

@ -118,6 +118,17 @@ export class SQLConnection {
}
}
}
// Add dummy Admin to the db
const admins = await userRepository.find({role: UserRoles.Admin});
if (admins.length === 0) {
const a = new UserEntity();
a.name = 'admin';
a.password = PasswordHelper.cryptPassword('admin');
a.role = UserRoles.Admin;
await userRepository.save(a);
}
const defAdmin = await userRepository.findOne({name: 'admin', role: UserRoles.Admin});
if (defAdmin && PasswordHelper.comparePassword('admin', defAdmin.password)) {
NotificationManager.error('Using default admin user!', 'You are using the default admin/admin user/password, please change or remove it.');

View File

@ -106,8 +106,7 @@ export class ServerDataBaseConfig {
arrayType: UserConfig,
description: 'Creates these users in the DB if they do not exist. If a user with this name exist, it wont be overwritten, even if the role is different.'
})
enforcedUsers: UserConfig[] = [new UserConfig('admin', 'admin', UserRoles.Admin)];
enforcedUsers: UserConfig[] = [];
}
@SubConfigClass()