From 54156b385b9c572619edf959d3a88f7bf0ae920d Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 16 Jun 2023 17:11:34 +0200 Subject: [PATCH] allow device registration from older Cryptomator desktop clients --- .../src/main/java/org/cryptomator/hub/api/DeviceResource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/org/cryptomator/hub/api/DeviceResource.java b/backend/src/main/java/org/cryptomator/hub/api/DeviceResource.java index 5bfdfa3e..efd8bdfa 100644 --- a/backend/src/main/java/org/cryptomator/hub/api/DeviceResource.java +++ b/backend/src/main/java/org/cryptomator/hub/api/DeviceResource.java @@ -74,7 +74,7 @@ public Response createOrUpdate(@Valid @NotNull DeviceDto dto, @PathParam("device device.id = deviceId; device.owner = User.findById(jwt.getSubject()); device.creationTime = Instant.now().truncatedTo(ChronoUnit.MILLIS); - device.type = dto.type; + device.type = dto.type != null ? dto.type : Device.Type.DESKTOP; // default to desktop for backwards compatibility } device.name = dto.name; device.publickey = dto.publicKey; @@ -155,7 +155,7 @@ public Response remove(@PathParam("deviceId") @ValidId String deviceId) { public record DeviceDto(@JsonProperty("id") @ValidId String id, @JsonProperty("name") @NoHtmlOrScriptChars @NotBlank String name, - @JsonProperty("type") @NotNull Device.Type type, + @JsonProperty("type") Device.Type type, @JsonProperty("publicKey") @NotNull @OnlyBase64UrlChars String publicKey, // for historic reasons, the device public key is base64url-encoded, instead of base64 @JsonProperty("userKey") @ValidJWE String userKey, @JsonProperty("owner") @ValidId String ownerId,