mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 23:06:10 +03:00
Use cookie session for logout route.
This commit is contained in:
parent
1becbff897
commit
b0cab3cc7d
@ -6,12 +6,14 @@ import DataSource.Http
|
||||
import Html exposing (Html)
|
||||
import Json.Decode
|
||||
import Json.Encode
|
||||
import MySession
|
||||
import OptimizedDecoder as Decode
|
||||
import Route exposing (Route)
|
||||
import Secrets
|
||||
import Server.Request
|
||||
import Server.Response
|
||||
import Server.SetCookie as SetCookie
|
||||
import Session
|
||||
|
||||
|
||||
routes :
|
||||
@ -185,17 +187,13 @@ nonHybridRoute =
|
||||
logout : ApiRoute ApiRoute.Response
|
||||
logout =
|
||||
ApiRoute.succeed
|
||||
(Server.Request.succeed
|
||||
(DataSource.succeed
|
||||
(Server.Response.plainText "You are logged out"
|
||||
|> Server.Response.withHeader "Set-Cookie"
|
||||
(SetCookie.setCookie "username" ""
|
||||
|> SetCookie.httpOnly
|
||||
|> SetCookie.withPath "/"
|
||||
|> SetCookie.withImmediateExpiration
|
||||
|> SetCookie.toString
|
||||
)
|
||||
)
|
||||
(MySession.withSession
|
||||
(Server.Request.succeed ())
|
||||
(\() sessionResult ->
|
||||
DataSource.succeed
|
||||
( Session.empty
|
||||
, Server.Response.temporaryRedirect "/login"
|
||||
)
|
||||
)
|
||||
)
|
||||
|> ApiRoute.literal "api"
|
||||
|
Loading…
Reference in New Issue
Block a user