Skip to content
Browse files

Expose the underlying password verification function as well

  • Loading branch information...
1 parent 6047c55 commit 0505fe5b1b436dbc5029894f6d087c6c544701f6 @ozataman ozataman committed Jan 12, 2012
Showing with 13 additions and 2 deletions.
  1. +2 −1 src/Snap/Snaplet/Auth.hs
  2. +11 −1 src/Snap/Snaplet/Auth/Types.hs
View
3 src/Snap/Snaplet/Auth.hs
@@ -49,10 +49,11 @@ module Snap.Snaplet.Auth
-- * Other Utilities
, withBackend
, encryptPassword
- , encrypt
, checkPassword
, authenticatePassword
, setPassword
+ , encrypt
+ , verify
-- * Handlers
, registerUser
View
12 src/Snap/Snaplet/Auth/Types.hs
@@ -41,6 +41,16 @@ encrypt :: ByteString -> IO ByteString
encrypt = flip makePassword defaultStrength
+-------------------------------------------------------------------------------
+-- | The underlying verify function, in case you need it for external
+-- processing.
+verify
+ :: ByteString -- ^ Cleartext
+ -> ByteString -- ^ Encrypted reference
+ -> Bool
+verify = verifyPassword
+
+
------------------------------------------------------------------------------
-- | Turn a 'ClearText' password into an 'Encrypted' password, ready to
-- be stuffed into a database.
@@ -51,7 +61,7 @@ encryptPassword (ClearText p) = Encrypted `fmap` encrypt p
------------------------------------------------------------------------------
checkPassword :: Password -> Password -> Bool
-checkPassword (ClearText pw) (Encrypted pw') = verifyPassword pw pw'
+checkPassword (ClearText pw) (Encrypted pw') = verify pw pw'
checkPassword (ClearText pw) (ClearText pw') = pw == pw'
checkPassword (Encrypted pw) (Encrypted pw') = pw == pw'
checkPassword _ _ =

0 comments on commit 0505fe5

Please sign in to comment.
Something went wrong with that request. Please try again.