From 22061e3f4ae9dbc4ef5ff1905cf0367f2d340b06 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Sun, 21 Apr 2024 10:02:23 -0600 Subject: [PATCH] Add logout link in sidebar --- .../com/wbrawner/twigs/web/user/UserWebRoutes.kt | 8 ++++++++ .../resources/templates/partials/sidebar.mustache | 11 +++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/web/src/main/kotlin/com/wbrawner/twigs/web/user/UserWebRoutes.kt b/web/src/main/kotlin/com/wbrawner/twigs/web/user/UserWebRoutes.kt index d29f48c..7e79892 100644 --- a/web/src/main/kotlin/com/wbrawner/twigs/web/user/UserWebRoutes.kt +++ b/web/src/main/kotlin/com/wbrawner/twigs/web/user/UserWebRoutes.kt @@ -37,6 +37,14 @@ fun Application.userWebRoutes(userService: UserService) { } } } + + route("/logout") { + post { + call.sessions.clear() + call.respondRedirect("/") + } + } + route("/register") { get { call.respond(MustacheContent("register.mustache", RegisterPage())) diff --git a/web/src/main/resources/templates/partials/sidebar.mustache b/web/src/main/resources/templates/partials/sidebar.mustache index 7a1e695..db4f9d5 100644 --- a/web/src/main/resources/templates/partials/sidebar.mustache +++ b/web/src/main/resources/templates/partials/sidebar.mustache @@ -40,13 +40,12 @@ About Twigs - TODO: Implement logout -
  • - - Logout - -
  • --> +
  • +
    + +
    +
  • Source Code