You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: playshogi-website/playshogi-website-server/src/main/java/com/playshogi/website/gwt/server/services/LessonServiceImpl.java
+26-3Lines changed: 26 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,12 @@ public void addLessonToCampaign(final String sessionId, final String campaignId,
105
105
if (loginResult == null || !loginResult.isLoggedIn()) {
106
106
thrownewIllegalStateException("Only logged in users can add a lesson in campaign");
107
107
}
108
-
//TODO: auth
108
+
109
+
// Authorization Check: Check if the current user is the author of the campaign
110
+
if (!lessonRepository.isCampaignAuthor(Integer.parseInt(campaignId), loginResult.getUserId())) {
111
+
thrownewIllegalStateException("User " + loginResult.getUserId() + " is not authorized to modify campaign "
112
+
+ campaignId);
113
+
}
109
114
110
115
if (!lessonRepository.addLessonToCampaign(newPersistentCampaignLesson(Integer.parseInt(campaignId),
111
116
Integer.parseInt(lessonId), x, y, false,
@@ -133,7 +138,13 @@ public void updateCampaignNode(final String sessionId, final String campaignId,
0 commit comments