From b209b3aa18db7bf3b2095ce924edb09ffb831542 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 4 Apr 2024 17:28:59 -0700 Subject: Default to registration disabled --- src/main/java/org/traccar/api/resource/UserResource.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/traccar/api/resource') diff --git a/src/main/java/org/traccar/api/resource/UserResource.java b/src/main/java/org/traccar/api/resource/UserResource.java index 47ea9b07c..fbc31e46a 100644 --- a/src/main/java/org/traccar/api/resource/UserResource.java +++ b/src/main/java/org/traccar/api/resource/UserResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2024 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,9 @@ public class UserResource extends BaseObjectResource { } } } else { - if (!permissionsService.getServer().getRegistration()) { + if (UserUtil.isEmpty(storage)) { + entity.setAdministrator(true); + } else if (!permissionsService.getServer().getRegistration()) { throw new SecurityException("Registration disabled"); } if (permissionsService.getServer().getBoolean(Keys.WEB_TOTP_FORCE.getKey()) @@ -106,10 +108,6 @@ public class UserResource extends BaseObjectResource { } } - if (UserUtil.isEmpty(storage)) { - entity.setAdministrator(true); - } - entity.setId(storage.addObject(entity, new Request(new Columns.Exclude("id")))); storage.updateObject(entity, new Request( new Columns.Include("hashedPassword", "salt"), -- cgit v1.2.3