From 3dfcd30f4e16624c05e88e9561a00d6d32c40f10 Mon Sep 17 00:00:00 2001 From: tommi27 Date: Wed, 4 Mar 2020 17:01:09 +0100 Subject: [PATCH] Fixed POST /room (Git merge I will avenge you) --- .../sa4/sanmarinoes/smarthut/controller/RoomController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java index 8c51b23..05850a3 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java @@ -9,7 +9,6 @@ import java.util.*; import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.*; -import org.springframework.security.core.userdetails.UserDetails; import org.springframework.web.bind.annotation.*; @RestController @@ -36,12 +35,13 @@ public class RoomController { private Room save(final RoomSaveRequest r, final Principal principal, boolean setWhenNull) { Room newRoom = new Room(); - final String username = ((UserDetails) principal).getUsername(); + final String username = principal.getName(); final Long userId = userRepository.findByUsername(username).getId(); final String img = r.getImage(); final String icon = r.getIcon(); newRoom.setUserId(userId); + newRoom.setName(r.getName()); if (img != null) { newRoom.setImage(img.getBytes()); } else if (setWhenNull) {