[MRM-1937] Prevent creation of wrong initial admin

Throws a error, if the admin user has the wrong name.
This commit is contained in:
Martin Stockhammer 2017-04-14 21:01:39 +02:00
parent db185cb79d
commit a3ee32699b
3 changed files with 7 additions and 0 deletions

View File

@ -103,6 +103,7 @@ cannot.register.user=Unable to process new user registration request.
invalid.admin.credentials=Invalid admin credentials, try again.
admin.user.already.exists=Admin User exists in database (someone else probably created the user before you).
cannot.assign.admin.role=Unable to assign system administrator role.
admin.wrongUsername=The username for the primary administrator must be 'admin'.
# --------------------------------------------------
# AssignmentsAction

View File

@ -94,6 +94,7 @@ invalid.admin.credentials=Ung\u00FCltige Administrations-Legitimationsdaten. Bit
admin.user.already.exists=Der Administrator existiert bereits. Evtl. wurde der Administrator bereits von jemand anderem angelegt, bevor Sie die M\u00F6glichkeit dazu hatten.
cannot.assign.admin.role=System-Administrator Rolle kann nicht zugewiesen werden.
admin.wrongUsername=Der Name für den prim\u00E4ren Administrator mu\u00DF 'admin' lauten.
# --------------------------------------------------
# AssignmentsAction
# --------------------------------------------------

View File

@ -504,6 +504,11 @@ public class DefaultUserService
{
return Boolean.FALSE;
}
log.debug("Creating admin admin user '{}'", adminUser.getUsername());
if (!RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME.equals(adminUser.getUsername())) {
log.error("Wrong admin user name {}", adminUser.getUsername());
throw new RedbackServiceException(new ErrorMessage("admin.wrongUsername"));
}
try
{