mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-28 17:55:06 +00:00
Use same meta data for creating and deleting cookie
The cookie might not be removed by browsers, if these infos don't match.
This commit is contained in:
parent
fd311b9688
commit
f747c6146d
@ -34,4 +34,16 @@ object CookieData {
|
|||||||
def fromHeader[F[_]](req: Request[F]): Either[String, String] = {
|
def fromHeader[F[_]](req: Request[F]): Either[String, String] = {
|
||||||
req.headers.get(CaseInsensitiveString(headerName)).map(_.value).toRight("Couldn't find an authenticator")
|
req.headers.get(CaseInsensitiveString(headerName)).map(_.value).toRight("Couldn't find an authenticator")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def deleteCookie(cfg: Config): ResponseCookie =
|
||||||
|
ResponseCookie(
|
||||||
|
cookieName,
|
||||||
|
"",
|
||||||
|
domain = cfg.baseUrl.host,
|
||||||
|
path = Some(cfg.baseUrl.path / "api" / "v1" / "sec").map(_.asString),
|
||||||
|
httpOnly = true,
|
||||||
|
secure = cfg.baseUrl.scheme.exists(_.endsWith("s")),
|
||||||
|
maxAge = Some(-1)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ object LoginRoutes {
|
|||||||
flatMap(res => makeResponse(dsl, cfg, res, ""))
|
flatMap(res => makeResponse(dsl, cfg, res, ""))
|
||||||
|
|
||||||
case POST -> Root / "logout" =>
|
case POST -> Root / "logout" =>
|
||||||
Ok().map(_.addCookie(ResponseCookie(CookieData.cookieName, "", maxAge = Some(-1))))
|
Ok().map(_.addCookie(CookieData.deleteCookie(cfg)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user