Merge branch 'scene-guest-fix' into 'dev'

Scene guest fix

See merge request sa4-2020/the-sanmarinoes/backend!113
This commit is contained in:
Claudio Maggioni 2020-05-05 16:36:16 +02:00
commit 5649ca9c29
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);
} }