https://github.com/zudov/purescript-yesod-auth
Bindings to `yesod-auth` endpoints.
https://github.com/zudov/purescript-yesod-auth
Last synced: 6 months ago
JSON representation
Bindings to `yesod-auth` endpoints.
- Host: GitHub
- URL: https://github.com/zudov/purescript-yesod-auth
- Owner: zudov
- License: bsd-3-clause
- Created: 2016-02-02T04:08:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-10T08:48:52.000Z (over 10 years ago)
- Last Synced: 2026-02-02T00:24:53.139Z (6 months ago)
- Language: PureScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# purescript-yesod-auth
Bindings to `yesod-auth` endpoints.
`test/` directory contains a runnable example. Start the server by executing
`./test/Main.hs` (requires `stack`) and launch `pulp test` to do some queries
against it.
Here is a glimse at the API:
```haskell
import Yesod.Auth (login, logout, LoginSuccess(..), LoginFailure(..))
import Yesod.Auth.Plugin (hardcoded)
let authRoute =
{ scheme: Just (URIScheme "http")
, authority: Just (Authority Nothing [Tuple (NameAddress "missile.dog") Nothing])
, path: rootDir > dir "auth"
}
result <- login authRoute hardcoded "username" "password"
case result of
Right LoginSuccess
-> do alert "Welcome!"
alert "Now lets launch missiles"
Ajax.post "http://missile.dog/launch" "Poehali"
alert "Now we gonna log you out"
logout authRoute
Left (LoginUsernameNotFound username)
-> alert ("We don't know of any " <> username)
Left LoginInvalid
-> alert "Your credentials are invalid, go away."
Left (LoginError msg)
-> alert ("Failed to login. " <> msg)
```
Yesod persists authentication using cookies, so credentials become a part of
implicit global state, keep that in mind and handle appropriately.