Skip to content

Commit

Permalink
Update for new auth changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mightybyte committed Nov 9, 2015
1 parent ed24fe8 commit 89a1be8
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Snap/Snaplet/Auth/Backends/PostgresqlSimple.hs
Expand Up @@ -42,7 +42,6 @@ import Control.Lens ((^#))
import Control.Monad.IO.Class (liftIO)
import Control.Monad (liftM, when, void)
import qualified Data.Configurator as C
import qualified Data.HashMap.Lazy as HM
import qualified Data.Text as T
import Data.Text (Text)
import qualified Data.Text.Encoding as T
Expand Down Expand Up @@ -89,6 +88,7 @@ initPostgresAuth sess db = makeSnaplet "postgresql-auth" desc datadir $ do
, activeUser = Nothing
, minPasswdLen = asMinPasswdLen authSettings
, rememberCookieName = asRememberCookieName authSettings
, rememberCookieDomain = asRememberCookieDomain authSettings
, rememberPeriod = asRememberPeriod authSettings
, siteKey = key
, lockout = asLockout authSettings
Expand Down Expand Up @@ -127,8 +127,8 @@ buildUid = UserId . T.pack . show
instance FromField UserId where
fromField f v = buildUid <$> fromField f v

instance FromField Password where
fromField f v = Encrypted <$> fromField f v
instance FromField HashedPassword where
fromField f v = HashedPassword <$> fromField f v

instance FromRow AuthUser where
fromRow =
Expand All @@ -151,8 +151,6 @@ instance FromRow AuthUser where
<*> _userUpdatedAt
<*> _userResetToken
<*> _userResetRequestedAt
<*> _userRoles
<*> _userMeta
where
!_userId = field
!_userLogin = field
Expand All @@ -172,8 +170,6 @@ instance FromRow AuthUser where
!_userUpdatedAt = field
!_userResetToken = field
!_userResetRequestedAt = field
!_userRoles = pure []
!_userMeta = pure HM.empty


querySingle :: (ToRow q, FromRow a)
Expand All @@ -187,9 +183,8 @@ authExecute pc q ps = do
withConnection pc $ \conn -> P.execute conn q ps
return ()

instance P.ToField Password where
toField (ClearText bs) = P.toField bs
toField (Encrypted bs) = P.toField bs
instance P.ToField HashedPassword where
toField pw = P.toField $ hashedByteString pw


-- | Datatype containing the names of the columns for the authentication table.
Expand Down

0 comments on commit 89a1be8

Please sign in to comment.