New AuthId type synonym.

This commit is contained in:
Felipe Lessa 2015-05-25 21:23:06 -03:00
parent fef17ea919
commit c44e5c6103
2 changed files with 11 additions and 3 deletions

View File

@ -2,6 +2,7 @@
module Web.ServerSession.Core module Web.ServerSession.Core
( -- * For serversession storage backends ( -- * For serversession storage backends
SessionId SessionId
, AuthId
, Session(..) , Session(..)
, Storage(..) , Storage(..)

View File

@ -6,6 +6,7 @@ module Web.ServerSession.Core.Internal
, generateSessionId , generateSessionId
, SessionMap , SessionMap
, AuthId
, Session(..) , Session(..)
, Storage(..) , Storage(..)
@ -112,6 +113,10 @@ generateSessionId = fmap S . N.nonce128urlT
type SessionMap = M.Map Text ByteString type SessionMap = M.Map Text ByteString
-- | Value of the 'authKey' session key.
type AuthId = ByteString
-- | Representation of a saved session. -- | Representation of a saved session.
-- --
-- This representation is used by the @serversession@ family of -- This representation is used by the @serversession@ family of
@ -123,7 +128,7 @@ data Session =
Session Session
{ sessionKey :: SessionId { sessionKey :: SessionId
-- ^ Session ID, primary key. -- ^ Session ID, primary key.
, sessionAuthId :: Maybe ByteString , sessionAuthId :: Maybe AuthId
-- ^ Value of 'authKey' session key, separate from the rest. -- ^ Value of 'authKey' session key, separate from the rest.
, sessionData :: SessionMap , sessionData :: SessionMap
-- ^ Rest of the session data. -- ^ Rest of the session data.
@ -150,7 +155,7 @@ class MonadIO (TransactionM s) => Storage s where
deleteSession :: s -> SessionId -> TransactionM s () deleteSession :: s -> SessionId -> TransactionM s ()
-- | Delete all sessions of the given auth ID. -- | Delete all sessions of the given auth ID.
deleteAllSessionsOfAuthId :: s -> ByteString -> TransactionM s () deleteAllSessionsOfAuthId :: s -> AuthId -> TransactionM s ()
-- | Insert a new session. -- | Insert a new session.
insertSession :: s -> Session -> TransactionM s () insertSession :: s -> Session -> TransactionM s ()
@ -162,7 +167,9 @@ class MonadIO (TransactionM s) => Storage s where
---------------------------------------------------------------------- ----------------------------------------------------------------------
-- TODO: do not create empty sessions -- TODO: do not create empty sessions.
-- TODO: delete expired sessions.
-- | The server-side session backend needs to maintain some state -- | The server-side session backend needs to maintain some state
-- in order to work: -- in order to work: