From 6061db04b2d82dffc5c04705735d9192176d3715 Mon Sep 17 00:00:00 2001 From: efim Date: Fri, 28 Jul 2023 16:05:15 +0000 Subject: [PATCH] feat: logout url redirecting to root and removing the cookie. this is mud and stick technologies --- src/main/resources/public/out.css | 33 ++++++++++++++++++++++++ src/main/resources/templates/index.html | 3 ++- src/main/scala/example/AuthService.scala | 33 ++++++++++++++++++++++-- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/main/resources/public/out.css b/src/main/resources/public/out.css index 29d148a..57fd05c 100644 --- a/src/main/resources/public/out.css +++ b/src/main/resources/public/out.css @@ -522,6 +522,30 @@ video { --tw-backdrop-sepia: ; } +.absolute { + position: absolute; +} + +.relative { + position: relative; +} + +.end-2 { + inset-inline-end: 0.5rem; +} + +.top-2 { + top: 0.5rem; +} + +.end-4 { + inset-inline-end: 1rem; +} + +.top-4 { + top: 1rem; +} + .flex { display: flex; } @@ -632,6 +656,15 @@ video { color: rgb(37 99 235 / var(--tw-text-opacity)); } +.text-blue-800 { + --tw-text-opacity: 1; + color: rgb(30 64 175 / var(--tw-text-opacity)); +} + +.underline { + text-decoration-line: underline; +} + .filter { filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow); } diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index b496eeb..ce7ec53 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -24,7 +24,8 @@ your experience.

-
+
+ Logout

Auth successful, yay diff --git a/src/main/scala/example/AuthService.scala b/src/main/scala/example/AuthService.scala index c4cb553..4baf44e 100644 --- a/src/main/scala/example/AuthService.scala +++ b/src/main/scala/example/AuthService.scala @@ -89,7 +89,10 @@ case class AuthService()(implicit cc: castor.Context, log: cask.Logger) val context = new PageContext() context.setVariable("iconLocationsMap", iconLocations.asJava) - context.setVariable("oauthProvidersList", authOptions.authProviders.sortBy(_.name).asJava) + context.setVariable( + "oauthProvidersList", + authOptions.authProviders.sortBy(_.name).asJava + ) context.setVariable("redirectUrl", oauthLinks.asJava) val authPage = templateEngine.process("auth", context) @@ -100,7 +103,9 @@ case class AuthService()(implicit cc: castor.Context, log: cask.Logger) val githubOption = authOptions.authProviders.find(_.name == "github") val githubRedirect = - githubOption.map(_.authUrl).getOrElse("") ++ getRedirectLandingUrl("github") + githubOption.map(_.authUrl).getOrElse("") ++ getRedirectLandingUrl( + "github" + ) cask.Response( authPage, @@ -191,6 +196,30 @@ case class AuthService()(implicit cc: castor.Context, log: cask.Logger) okMessageFirst } + @cask.get(s"/logout") + def logoutAndRedirectToRoot() = { + println(s"about to logout") + + val redirectToIndex = renderRedirectPage( + "/", + "You will be redirected to home page soon", + 0 + ) + + cask.Response( + redirectToIndex, + headers = Seq("Content-Type" -> "text/html;charset=UTF-8"), + cookies = Seq( + cask.Cookie( + name = authCookieName, + value = "", + path = "/", + expires = Instant.EPOCH + ) + ) + ) + } + @cask.staticResources("/public") def servePublicResources() = "public"