snaplet-sqlite-simple- sqlite-simple snaplet for the Snap Framework

Safe HaskellNone




This module allows you to use the auth snaplet with your user database stored in a SQLite database. When you run your application with this snaplet, a config file will be copied into the the snaplets/sqlite-auth directory. This file contains all of the configurable options for the snaplet and allows you to change them without recompiling your application.

To use this snaplet in your application enable the session, sqlite, and auth snaplets as follows:

data App = App
    { ... -- your own application state here
    , _sess :: Snaplet SessionManager
    , _db   :: Snaplet Sqlite
    , _auth :: Snaplet (AuthManager App)

Then in your initializer you'll have something like this:

d <- nestSnaplet "db" db sqliteInit
a <- nestSnaplet "auth" auth $ initSqliteAuth sess d

If you have not already created the database table for users, it will automatically be created for you the first time you run your application.



initSqliteAuth Source #


:: SnapletLens b SessionManager

Lens to the session snaplet

-> Snaplet Sqlite

The sqlite snaplet

-> SnapletInit b (AuthManager b) 

Initializer for the sqlite backend to the auth snaplet.

mkSqliteAuthMgr :: Text -> MVar Connection -> SqliteAuthManager Source #

Construct sqlite-simple auth manager

Can be used in command line tools

Orphan instances