feat: logout url redirecting to root

and removing the cookie.
this is mud and stick technologies
This commit is contained in:
efim 2023-07-28 16:05:15 +00:00
parent dd5d255742
commit 6061db04b2
3 changed files with 66 additions and 3 deletions

View File

@ -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);
}

View File

@ -24,7 +24,8 @@
your experience.
</p>
<![endif]-->
<main class="bg-blue-100 h-screen w-screen grid place-content-center">
<main class="bg-blue-100 h-screen w-screen grid place-content-center relative">
<a href="/logout" class="absolute end-4 top-4 underline text-blue-800 font-bold">Logout</a>
<section>
<h1 class="text-2xl text-blue-600 font-bold tracking-wide uppercase">
Auth successful, yay

View File

@ -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"