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:
parent
a4a9fe2c98
commit
b169fa67b3
@ -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.');
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user