From 1ef877d8d370d0f2154f915e854d878a80deffe5 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 11 Dec 2024 16:10:30 +0100 Subject: [PATCH] SEBSP-182 implementation --- .../servicelayer/authorization/TeacherAccountService.java | 2 ++ .../authorization/impl/TeacherAccountServiceImpl.java | 5 ++++- .../webservice/weblayer/api/LmsIntegrationController.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java index 2b2f26513..ddc38b9f6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java @@ -12,6 +12,8 @@ import ch.ethz.seb.sebserver.gbl.model.user.TokenLoginInfo; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.util.Result; +import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamFinishedEvent; +import org.springframework.context.event.EventListener; /** Service used to maintain Teacher Ad-Hoc Accounts */ public interface TeacherAccountService { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java index 8f39d144b..ae9d447a3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java @@ -24,6 +24,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.TeacherAccountService; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserDAO; +import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamFinishedEvent; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ScreenProctoringService; import ch.ethz.seb.sebserver.webservice.weblayer.oauth.AdminAPIClientDetails; import io.jsonwebtoken.Claims; @@ -133,7 +134,9 @@ public Result getOneTimeTokenForTeacherAccount( final AdHocAccountData adHocAccountData, final boolean createIfNotExists) { - // TODO check if Exam is running, if not deny access + if (exam.status != Exam.ExamStatus.RUNNING) { + return Result.ofError(new IllegalStateException("Exam is not running")); + } return this.userDAO .byModelId(getTeacherAccountIdentifier(exam, adHocAccountData)) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java index 1a1bfdc88..92e799fe6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsIntegrationController.java @@ -198,7 +198,7 @@ public FullLmsIntegrationService.TokenLoginResponse getOneTimeLoginToken( final String token = this.fullLmsIntegrationService .getOneTimeLoginToken(lmsUUId, courseId, quizId, adHocAccountData) - .onError(error -> log.error("Failed to create ad-hoc account with one time login token, error: {}", error.getMessage())) + .onError(error -> log.warn("Failed to create ad-hoc account with one time login token, error: {}", error.getMessage())) .getOrThrow(); return new FullLmsIntegrationService.TokenLoginResponse(