~jan0sch/smederee
Showing details for patch fbd56aa27d5bd3c3e7e9e9031dafbd273f3c4caa.
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-01 15:44:21.885687531 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala 2025-02-01 15:44:21.885687531 +0000 @@ -81,7 +81,7 @@ form <- Sync[F].delay(LoginForm.validate(formData)) response <- form match { case Validated.Invalid(es) => - BadRequest.apply( + BadRequest( views.html.login()(loginPath, csrf, title = "Smederee - Login to your account".some)( formData, FormErrors.fromNec(es) @@ -118,7 +118,7 @@ } response <- login match { case None => - BadRequest.apply( + BadRequest( views.html.login()(loginPath, csrf, title = "Smederee - Login to your account".some)( formData, Map(LoginForm.fieldGlobal -> List(FormFieldError("Invalid credentials!"))) @@ -138,13 +138,8 @@ token <- Sync[F].delay( signAndValidate.signToken(session.id.toString)(clock.millis.toString) ) - response <- SeeOther - .apply(Location(Uri(path = Uri.Path.Root))) - .map( - _.addCookie( - token.toAuthenticationCookie(None)(secure = true) - ) - ) + response <- SeeOther(Location(Uri(path = Uri.Path.Root))) + .map(_.addCookie(token.toAuthenticationCookie(None)(secure = true))) } yield response } } yield response @@ -155,7 +150,7 @@ private val parseLoginFormForLoggedInUsers: AuthedRoutes[Account, F] = AuthedRoutes.of { case ar @ POST -> Root / "login" as _ => - SeeOther.apply(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. + SeeOther(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. } // private val parseResetPasswordForm = ??? @@ -165,24 +160,20 @@ authToken <- Sync[F].delay(ar.req.getAuthenticationToken) sessionId <- Sync[F].delay(authToken.flatMap(signAndValidate.validate).flatMap(SessionId.from)) _ <- sessionId.traverse(repo.deleteUserSession) - response <- SeeOther - .apply(Location(loginPath)) - .map(_.removeCookie(Constants.authenticationCookieName.toString)) + response <- SeeOther(Location(loginPath)).map(_.removeCookie(Constants.authenticationCookieName.toString)) } yield response } private val showLoginForm: HttpRoutes[F] = HttpRoutes.of { case req @ GET -> Root / "login" => for { - csrf <- Sync[F].delay(req.getCsrfToken) - response <- Ok.apply( - views.html.login()(loginPath, csrf, title = "Smederee - Login to your account".some)() - ) + csrf <- Sync[F].delay(req.getCsrfToken) + response <- Ok(views.html.login()(loginPath, csrf, title = "Smederee - Login to your account".some)()) } yield response } private val showLoginFormForLoggedInUsers: AuthedRoutes[Account, F] = AuthedRoutes.of { case ar @ GET -> Root / "login" as _ => - SeeOther.apply(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. + SeeOther(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. } // private val showResetPasswordForm = ??? 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-01 15:44:21.885687531 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/SignupRoutes.scala 2025-02-01 15:44:21.885687531 +0000 @@ -95,7 +95,7 @@ } resp <- checkExisting match { case Validated.Invalid(es) => - BadRequest.apply( + BadRequest( views.html .signup()(signupUri, csrf, "Smederee - Sign up for an account".some)( formData, @@ -105,7 +105,7 @@ case Validated.Valid(innerValidation) => innerValidation match { case Validated.Invalid(es) => - BadRequest.apply( + BadRequest( views.html .signup()(signupUri, csrf, "Smederee - Sign up for an account".some)( formData, @@ -126,7 +126,7 @@ hash <- Sync[F].delay(signupForm.password.encode) _ <- Sync[F].delay(log.info(s"Going to create account for ${account.name}.")) _ <- repo.createAccount(account, PasswordHash(hash)) - redirect <- SeeOther.apply(Location(signupUri.addPath("welcome"))) + redirect <- SeeOther(Location(signupUri.addPath("welcome"))) } yield redirect } } @@ -136,7 +136,7 @@ private val parseSignUpFormForLoggedInUsers: AuthedRoutes[Account, F] = AuthedRoutes.of { case ar @ POST -> Root / "signup" as _ => - SeeOther.apply(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. + SeeOther(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. } // Render the signup form. @@ -149,7 +149,7 @@ private val showSignUpFormForLoggedInUsers: AuthedRoutes[Account, F] = AuthedRoutes.of { case ar @ GET -> Root / "signup" as _ => - SeeOther.apply(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. + SeeOther(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. } private val showWelcomePage: HttpRoutes[F] = HttpRoutes.of { case req @ GET -> Root / "signup" / "welcome" => diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-02-01 15:44:21.885687531 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-02-01 15:44:21.885687531 +0000 @@ -212,9 +212,7 @@ .compile .toList actionBaseUri <- Sync[F].delay(linkConfig.createFullUri(uri"projects")) - resp <- Ok.apply( - views.html.showAllRepositories()(actionBaseUri, csrf, s"Smederee - Projects".some, user)(repos) - ) + resp <- Ok(views.html.showAllRepositories()(actionBaseUri, csrf, s"Smederee - Projects".some, user)(repos)) } yield resp /** Logic for rendering a list of repositories of the given owner for a specific user account. This function takes @@ -240,7 +238,7 @@ ) resp <- owner match { case None => // TODO Better error message... - NotFound.apply( + NotFound( views.html.showRepositories()( actionBaseUri, csrf, @@ -249,7 +247,7 @@ )(repos.getOrElse(List.empty), repositoriesOwnerName) ) case Some(_) => - Ok.apply( + Ok( views.html.showRepositories()( actionBaseUri, csrf, @@ -554,7 +552,7 @@ resp <- repo match { case None => NotFound() case Some(repo) => - Ok.apply( + Ok( views.html.showRepositoryHistory(baseUri)( actionBaseUri, csrf, @@ -781,7 +779,7 @@ form <- Sync[F].delay(NewVcsRepositoryForm.validate(formData)) resp <- form match { case Validated.Invalid(es) => - BadRequest.apply( + BadRequest( views.html .createRepository()(createRepoPath, csrf, "Smederee - Create a new repository".some, user)( formData, @@ -828,7 +826,7 @@ } resp <- output.exitValue match { case 0 => - SeeOther.apply( + SeeOther( Location( Uri(path = Uri.Path.Root |+| Uri.Path(Vector(Uri.Path.Segment(s"~${user.name.toString}")))) ) @@ -840,7 +838,7 @@ s"Error creating the repository ${newVcsRepository.name} in directory $directory: ${output.stderr.toList.mkString}" ) ) - resp <- InternalServerError.apply( + resp <- InternalServerError( s"Error creating the repository: ${output.stderr.toList.mkString}" ) } yield resp