From 006a3ec48108dd844f291bf864bec801d0e36a65 Mon Sep 17 00:00:00 2001
From: Felipe D'Abrantes <felidabrantes@gmail>
Date: Tue, 11 Apr 2023 00:49:02 +0100
Subject: [PATCH] Use authentication middleware in GET endpoints

---
 .../feed-service/app/controllers/DailyController.scala | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/backend-services/feed-service/app/controllers/DailyController.scala b/backend-services/feed-service/app/controllers/DailyController.scala
index 2ae8ee00..69c00c4e 100644
--- a/backend-services/feed-service/app/controllers/DailyController.scala
+++ b/backend-services/feed-service/app/controllers/DailyController.scala
@@ -5,6 +5,7 @@ import play.api.mvc._
 import play.api.libs.json.{JsValue, JsLookupResult}
 
 import models.{Daily}
+import models.actions.{AuthenticatedUserAction}
 import models.exceptions.{ConflictException, NotFoundException, InvalidRequestBodyException, InvalidQueryParameterException}
 
 import scala.concurrent.TimeoutException
@@ -14,12 +15,13 @@ import org.bson.types.ObjectId
  * This controller handles all the Daily endpoints.
  */
 @Singleton
-class DailyController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {
+class DailyController @Inject()(val controllerComponents: ControllerComponents, authenticatedUserAction: AuthenticatedUserAction) 
+  extends BaseController {
 
   /**
    * Create an Action to fetch all the Dailies in the DB.
    */
-  def getAll() = Action {
+  def getAll() = authenticatedUserAction {
     println("DailyController:getAll")
 
     try {
@@ -37,7 +39,7 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
    * 
    * @param userId The ID of the user to get the dailies for.
    */
-  def getUserDailies(userId: String) = Action {
+  def getUserDailies(userId: String) = authenticatedUserAction {
     println("DailyController:getUserDailies")
 
     try {
@@ -58,7 +60,7 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents)
    * 
    * @param userId The ID of the user to get the feed for.
    */
-  def getUserFeed(userId: String) = Action {
+  def getUserFeed(userId: String) = authenticatedUserAction {
     println("DailyController:getUserFeed")
 
     try {
-- 
GitLab