Check Scene.guestAccessEnabled flag on guest application of scene

This commit is contained in:
Claudio Maggioni 2020-05-05 16:31:54 +02:00
parent 38c703e521
commit ddcdaccbe0
2 changed files with 3 additions and 2 deletions

View file

@ -70,7 +70,7 @@ public class SceneController {
Utils.returnIfGuest(userRepository, null, hostId, principal); Utils.returnIfGuest(userRepository, null, hostId, principal);
return sceneService.applyAsGuest( return sceneService.applyAsGuest(
sceneRepository sceneRepository
.findByIdAndUserId(id, hostId) .findByIdAndUserIdAndGuestAccessEnabled(id, hostId, true)
.orElseThrow(NotFoundException::new), .orElseThrow(NotFoundException::new),
principal.getName(), principal.getName(),
hostId); hostId);

View file

@ -23,5 +23,6 @@ public interface SceneRepository extends CrudRepository<Scene, Long> {
@Query("SELECT s FROM Scene s JOIN s.user u WHERE u.id = ?1 AND s.guestAccessEnabled = true") @Query("SELECT s FROM Scene s JOIN s.user u WHERE u.id = ?1 AND s.guestAccessEnabled = true")
List<Scene> findByHostId(Long hostId); List<Scene> findByHostId(Long hostId);
Optional<Scene> findByIdAndUserId(Long id, Long userId); Optional<Scene> findByIdAndUserIdAndGuestAccessEnabled(
Long id, Long userId, boolean guestAccessEnabled);
} }