From e4eff45298502406e635eb47b11fc99f5c889741 Mon Sep 17 00:00:00 2001 From: Vincent Velociter Date: Sat, 2 Nov 2024 11:57:21 +0100 Subject: [PATCH 1/2] [Mobile] Add missing mobile scopes to study endpoints --- app/controllers/Study.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/Study.scala b/app/controllers/Study.scala index e279852e081cc..1555e6e8ba082 100644 --- a/app/controllers/Study.scala +++ b/app/controllers/Study.scala @@ -417,7 +417,7 @@ final class Study( def pgn(id: StudyId) = Open: pgnWithFlags(id, identity) - def apiPgn(id: StudyId) = AnonOrScoped(_.Study.Read): ctx ?=> + def apiPgn(id: StudyId) = AnonOrScoped(_.Study.Read, _.Web.Mobile): ctx ?=> pgnWithFlags(id, identity) def pgnWithFlags(id: StudyId, flags: Update[WithFlags])(using Context) = @@ -439,7 +439,7 @@ final class Study( def chapterPgn(id: StudyId, chapterId: StudyChapterId) = Open: doChapterPgn(id, chapterId, notFound, privateUnauthorizedFu, privateForbiddenFu) - def apiChapterPgn(id: StudyId, chapterId: StudyChapterId) = AnonOrScoped(_.Study.Read): ctx ?=> + def apiChapterPgn(id: StudyId, chapterId: StudyChapterId) = AnonOrScoped(_.Study.Read, _.Web.Mobile): ctx ?=> doChapterPgn( id, chapterId, @@ -467,7 +467,7 @@ final class Study( } } - def exportPgn(username: UserStr) = OpenOrScoped(_.Study.Read): ctx ?=> + def exportPgn(username: UserStr) = OpenOrScoped(_.Study.Read, _.Web.Mobile): ctx ?=> val name = if username.value == "me" then ctx.me.fold(UserName("me"))(_.username) @@ -485,7 +485,7 @@ final class Study( .pipe(asAttachmentStream(s"${name}-${if isMe then "all" else "public"}-studies.pgn")) .as(pgnContentType) - def apiListByOwner(username: UserStr) = OpenOrScoped(_.Study.Read): ctx ?=> + def apiListByOwner(username: UserStr) = OpenOrScoped(_.Study.Read, _.Web.Mobile): ctx ?=> val isMe = ctx.is(username) apiC.jsonDownload: env.study.studyRepo From 3020054a398af30d3ef8d159f94f4e87130f8de7 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sun, 3 Nov 2024 11:57:24 +0100 Subject: [PATCH 2/2] sbt scalafmtAll --- app/controllers/Study.scala | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/Study.scala b/app/controllers/Study.scala index 1555e6e8ba082..1e8611250e0a7 100644 --- a/app/controllers/Study.scala +++ b/app/controllers/Study.scala @@ -439,14 +439,15 @@ final class Study( def chapterPgn(id: StudyId, chapterId: StudyChapterId) = Open: doChapterPgn(id, chapterId, notFound, privateUnauthorizedFu, privateForbiddenFu) - def apiChapterPgn(id: StudyId, chapterId: StudyChapterId) = AnonOrScoped(_.Study.Read, _.Web.Mobile): ctx ?=> - doChapterPgn( - id, - chapterId, - fuccess(studyNotFoundText), - _ => fuccess(privateUnauthorizedText), - _ => fuccess(privateForbiddenText) - ) + def apiChapterPgn(id: StudyId, chapterId: StudyChapterId) = + AnonOrScoped(_.Study.Read, _.Web.Mobile): ctx ?=> + doChapterPgn( + id, + chapterId, + fuccess(studyNotFoundText), + _ => fuccess(privateUnauthorizedText), + _ => fuccess(privateForbiddenText) + ) private def doChapterPgn( id: StudyId,