Skip to content

Commit

Permalink
fix admin login redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
thwbh committed Nov 7, 2024
1 parent dc308a3 commit 63826f0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/io/tohuwabohu/kamifusen/AppAdminResource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ class AppAdminResource(
.onFailure().recoverWithHtmxResponse(Response.Status.INTERNAL_SERVER_ERROR)

@Path("/logout")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@GET
@Produces(MediaType.TEXT_PLAIN)
fun logoutAdmin(@Context routingContext: RoutingContext): Uni<Response> =
Uni.createFrom().item(
Response.noContent().header("hx-redirect", "/")
Response.status(Response.Status.FOUND)
.cookie(
NewCookie.Builder(cookieName)
.maxAge(0)
.expiry(Date.from(Instant.EPOCH))
.path("/")
.build()
)
.header("Location", "/index.html")
.build()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ private fun FlowContent.renderNavigation(navId: String, isFirstTimeSetup: Boolea

div {
classes = setOf("ml-10", "flex", "items-baseline", "space-x-4")
a(href = "#") {
a(href = "/logout") {
classes = navInactiveClasses

attributes["hx-post"] = "/logout"

+"Logout"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@ fun FlowContent.passwordFlow(validation: PasswordValidation? = null) = div {
p { +"Successfully updated password!" }
div {
div {
button {
a(href = "/logout") {
classes = passwordButtonStyles

attributes["hx-post"] = "/logout"

+"Back to login"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ quarkus.http.auth.permission.basic.policy=authenticated

quarkus.http.auth.form.enabled=true
quarkus.http.auth.form.landing-page=/dashboard
quarkus.http.auth.form.login-page=index.html
quarkus.http.auth.form.login-page=/index.html
quarkus.http.auth.form.error-page=
quarkus.http.auth.form.post-location=/login
quarkus.http.auth.form.username-parameter=username
Expand Down

0 comments on commit 63826f0

Please sign in to comment.