|
|
|
@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.thingsboard.server.common.data.Customer; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
|
import org.thingsboard.server.common.data.User; |
|
|
|
@ -66,6 +67,24 @@ public class UserDataValidator extends DataValidator<User> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected User validateUpdate(TenantId tenantId, User user) { |
|
|
|
User old = userDao.findById(user.getTenantId(), user.getId().getId()); |
|
|
|
if (old == null) { |
|
|
|
throw new DataValidationException("Can't update non existing user!"); |
|
|
|
} |
|
|
|
if (!old.getTenantId().equals(user.getTenantId())) { |
|
|
|
throw new DataValidationException("Can't update user tenant id!"); |
|
|
|
} |
|
|
|
if (!old.getAuthority().equals(user.getAuthority())) { |
|
|
|
throw new DataValidationException("Can't update user authority!"); |
|
|
|
} |
|
|
|
if (!old.getCustomerId().equals(user.getCustomerId())) { |
|
|
|
throw new DataValidationException("Can't update user customer id!"); |
|
|
|
} |
|
|
|
return old; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void validateDataImpl(TenantId requestTenantId, User user) { |
|
|
|
if (StringUtils.isEmpty(user.getEmail())) { |
|
|
|
|