diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt index 39e4774..4655710 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/AuthFilter.kt @@ -46,7 +46,8 @@ class AuthFilter: Filter { private val whitelist = setOf( "/index-ffg", "/login", - "/api/login" + "/api/login", + "api/logout" ) fun whitelisted(uri: String): Boolean { diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/LogoutServlet.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/LogoutServlet.kt new file mode 100644 index 0000000..8ed8075 --- /dev/null +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/web/LogoutServlet.kt @@ -0,0 +1,17 @@ +package org.jeudego.pairgoth.web + +import com.republicate.kson.Json +import org.slf4j.LoggerFactory +import javax.servlet.http.HttpServlet +import javax.servlet.http.HttpServletRequest +import javax.servlet.http.HttpServletResponse + +class LogoutServlet: HttpServlet() { + + override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) { + req.session.removeAttribute("logged") + val ret = Json.Object("status" to "ok") + resp.contentType = "application/json" + resp.writer.println(ret.toString()) + } +} diff --git a/view-webapp/src/main/sass/main.scss b/view-webapp/src/main/sass/main.scss index 8e9b508..cd023e7 100644 --- a/view-webapp/src/main/sass/main.scss +++ b/view-webapp/src/main/sass/main.scss @@ -54,6 +54,12 @@ max-height: 100%; } } + #header-right { + display: flex; + flex-flow: row nowrap; + gap: 0.5em; + padding-right: 0.5em; + } } #center { diff --git a/view-webapp/src/main/webapp/WEB-INF/layouts/standard.html b/view-webapp/src/main/webapp/WEB-INF/layouts/standard.html index 3f344af..0970051 100644 --- a/view-webapp/src/main/webapp/WEB-INF/layouts/standard.html +++ b/view-webapp/src/main/webapp/WEB-INF/layouts/standard.html @@ -43,8 +43,15 @@

#if($tour)$esc.html($tour.name)#end

-
- +
+
+ +
+#if($session.logged) +
+ +
+#end
@@ -108,6 +115,14 @@ $('body').removeClass('dimmed'); } }); + $('#logout').on('click', e => { + api.postJson('logout', {}) + .then(ret => { + if (ret !== 'error') { + document.location.href = '/index'; + } + }); + }); }); // syntaxic sugar for IMask diff --git a/view-webapp/src/main/webapp/WEB-INF/web.xml b/view-webapp/src/main/webapp/WEB-INF/web.xml index d36618f..1f2f43e 100644 --- a/view-webapp/src/main/webapp/WEB-INF/web.xml +++ b/view-webapp/src/main/webapp/WEB-INF/web.xml @@ -94,6 +94,12 @@ 1 true + + logout + org.jeudego.pairgoth.web.LogoutServlet + 1 + true + @@ -120,6 +126,10 @@ login /api/login + + logout + /api/logout +