diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt index 389b125..aec45c3 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Security.kt @@ -40,7 +40,7 @@ class CustomWebSecurityConfigurerAdapter : WebSecurityConfigurerAdapter() { @Throws(Exception::class) override fun configure(http: HttpSecurity) { http.csrf().disable().authorizeRequests() - .antMatchers(HttpMethod.POST, "/api/site", "/api/tutor", "/api/observation").authenticated() + .antMatchers(HttpMethod.POST, "/api/site", "/api/tutor", "/api/observation", "/api/grpob/start").authenticated() .anyRequest().permitAll() .and() .httpBasic() diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/WebSocketConfig.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/WebSocketConfig.kt index 96b53ea..3562a7d 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/WebSocketConfig.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/WebSocketConfig.kt @@ -15,6 +15,6 @@ class WebSocketConfig : WebSocketMessageBrokerConfigurer { } override fun registerStompEndpoints(registry: StompEndpointRegistry) { - registry.addEndpoint("/websocket").withSockJS() + registry.addEndpoint("/websocket").setAllowedOrigins("http://localhost:8080", "http://127.0.0.1:8080").withSockJS() } } \ No newline at end of file diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/GroupSessionController.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/GroupSessionController.kt index 9a14163..7f92d10 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/GroupSessionController.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/GroupSessionController.kt @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.CrossOrigin import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController import uk.co.neviyn.observationdatabase.GroupObservation @@ -22,6 +23,7 @@ import uk.co.neviyn.observationdatabase.SiteRepository import uk.co.neviyn.observationdatabase.TutorRepository import java.net.Inet4Address import java.net.NetworkInterface +import javax.validation.Valid @RestController @RequestMapping("/api/grpob") @@ -45,7 +47,7 @@ class GroupSessionController { * Start a new Group Observation session */ @PostMapping("/start") - fun startGroupObservation(initData: GroupObservationInit): Map { + fun startGroupObservation(@Valid @RequestBody initData: GroupObservationInit): Map { val site = siteRepository.findById(initData.site) val tutors = tutorRepository.findAllById(initData.tutors).toSet() if (!site.isPresent) { @@ -65,8 +67,12 @@ class GroupSessionController { */ @GetMapping("/recover") fun reconnectToGroupObservation(): Map { - logger.debug("Previous group observation requested") - return getConnectionDetails().plus(mapOf("id" to GroupSessionManager.sessionId.toString(), "observations" to GroupSessionManager.observations)) + if (GroupSessionManager.isValid()) { + logger.info("Previous group observation requested, current id ${GroupSessionManager.sessionId}") + return getConnectionDetails().plus(mapOf("id" to GroupSessionManager.sessionId.toString(), "observations" to GroupSessionManager.observations)) + } + logger.info("Tried to recover a session but no session is active") + return mapOf("error" to "No session currently active") } /** diff --git a/frontend/src/views/GroupSession.vue b/frontend/src/views/GroupSession.vue index ddcc57c..d4b6253 100644 --- a/frontend/src/views/GroupSession.vue +++ b/frontend/src/views/GroupSession.vue @@ -11,7 +11,7 @@ - + @@ -43,17 +43,65 @@ + + + + + + + Delete + + + + + + Add Another Scenario + + + + +
+
+
Start - Connect to Previous Session + Connect to Previous Session
+ +
+ +
+
-}; -