Open abailly opened 8 years ago
Hey @abailly,
I'm currently using removeSession
but struggle with it. Do you have a code sample to see how you integrate it in a Servant app ?
Hello, Here is a place where I use it in my code:
doLogout :: AuthCookieSettings -> UserAccount -> m ()
doLogout settings _ = lift (removeSession settings ())
It's very simple actually... The tricky part is to understand where the session comes from.
@abailly Thanks for your reply !
My api is defined like this
"api" :> "logout" :> AuthProtect "cookie-auth" :> Get '[JSON] (Headers '[Header "Set-Cookie" ByteString] ())
And for the moment the handler looks like yours : logoutServer _ = removeSession settings ()
Though, I've got this error :
No instance for (ToHttpApiData ByteString)
arising from a use of ‘removeSession’
And I don't quite understand where the problem is 🤔
I have similar code and it works like a charm, except the action is POST
and not a GET
. For each AuthProtect a
you have to define which type is computed by type family AuthServerData
, e.g. :
type instance AuthServerData (AuthProtect "cookie-auth") = X
it might be that X
leads to some type which requires implementation of ToHttpApiData
?
I was inspired by what's in the example/
folder so I didn't had to write type instance AuthServerData ...
until now.
Here is the code if you have the time to take a quick look (sorry it's a bit drafty...)
It compiles OK here... Might be a version problem?
Arf, damned >.< Which stackage resolver are you using ?
7.10
-- Arnaud Bailly
twitter: abailly skype: arnaud-bailly linkedin: http://fr.linkedin.com/in/arnaudbailly/
On Fri, Jan 13, 2017 at 10:30 PM, Thomas Crevoisier < notifications@github.com> wrote:
Arf, damned >.< Which resolver are you using ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zohl/servant-auth-cookie/issues/22#issuecomment-272455751, or mute the thread https://github.com/notifications/unsubscribe-auth/AACdHTOYf6-Io_P1grZVS-q9343BGgduks5rR4qCgaJpZM4K8OI8 .
Do you point directly to the github repo of servant-auth-cookie
? I don't find the version 4.2 in this snapshot
hmm, yes.
-- Arnaud Bailly
twitter: abailly skype: arnaud-bailly linkedin: http://fr.linkedin.com/in/arnaudbailly/
On Fri, Jan 13, 2017 at 10:36 PM, Thomas Crevoisier < notifications@github.com> wrote:
Do you point directly to the github repo of servant-auth-cookie ? I don't find the version 4.2 in this snapshot https://www.stackage.org/haddock/lts-7.10/servant-auth-cookie-0.3.2/Servant-Server-Experimental-Auth-Cookie.html
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zohl/servant-auth-cookie/issues/22#issuecomment-272457058, or mute the thread https://github.com/notifications/unsubscribe-auth/AACdHTTfrWLoiz0LQSHsV7AE0aZvrQOuks5rR4vXgaJpZM4K8OI8 .
Could you share your stack.yaml
please ? ^^
It's really simple:
resolver: lts-7.10 packages:
commits
http-client-0.4.31.2
I think the problem comes from the version: I use a version from my fork as a submodule and it is not uptodate with HEAD.
-- Arnaud Bailly
twitter: abailly skype: arnaud-bailly linkedin: http://fr.linkedin.com/in/arnaudbailly/
On Fri, Jan 13, 2017 at 11:06 PM, Thomas Crevoisier < notifications@github.com> wrote:
Could you share your stack.yaml please ? ^^
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zohl/servant-auth-cookie/issues/22#issuecomment-272464668, or mute the thread https://github.com/notifications/unsubscribe-auth/AACdHTZ28gf1YjEPvZUY60Zp93e8zdzwks5rR5L9gaJpZM4K8OI8 .
There is a comment hinting at some way to do that:
but no corresponding function.