~jan0sch/smederee

Showing details for patch 64503b873a3bfa4533b85bfd2fb1af45c2aa1b06.
2022-09-05 (Mon), 1:36 PM - Jens Grassel - 64503b873a3bfa4533b85bfd2fb1af45c2aa1b06

Config: Disable Auth and Signup if configured so

Summary of changes
2 files modified with 23 lines added and 6 lines removed
  • modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala with 11 added and 3 removed lines
  • modules/hub/src/main/scala/de/smederee/hub/SignupRoutes.scala with 12 added and 3 removed lines
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala	2025-02-02 11:57:00.825191644 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala	2025-02-02 11:57:00.825191644 +0000
@@ -191,8 +191,16 @@
 
   // private val unlockUser = ???
 
-  val protectedRoutes = logout <+> showLoginFormForLoggedInUsers <+> parseLoginFormForLoggedInUsers
+  val protectedRoutes =
+    if (authenticationConfig.enabled)
+      logout <+> showLoginFormForLoggedInUsers <+> parseLoginFormForLoggedInUsers
+    else
+      AuthedRoutes.empty[Account, F]
 
-  val routes = showLoginForm <+> parseLoginForm
+  val routes =
+    if (authenticationConfig.enabled)
+      showLoginForm <+> parseLoginForm
+    else
+      HttpRoutes.empty[F]
 
 }
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/SignupRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/SignupRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/SignupRoutes.scala	2025-02-02 11:57:00.825191644 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/SignupRoutes.scala	2025-02-02 11:57:00.825191644 +0000
@@ -160,7 +160,16 @@
       } yield resp
   }
 
-  val protectedRoutes = showSignUpFormForLoggedInUsers <+> parseSignUpFormForLoggedInUsers
+  val protectedRoutes =
+    if (signupConfig.enabled)
+      showSignUpFormForLoggedInUsers <+> parseSignUpFormForLoggedInUsers
+    else
+      AuthedRoutes.empty[Account, F]
+
+  val routes =
+    if (signupConfig.enabled)
+      showSignUpForm <+> parseSignUpForm <+> showWelcomePage
+    else
+      HttpRoutes.empty[F]
 
-  val routes = showSignUpForm <+> parseSignUpForm <+> showWelcomePage
 }