packages feed

yesod-auth-bcrypt 0.1.0 → 0.1.1

raw patch · 2 files changed

+21/−49 lines, 2 filesdep −aesondep −authenticatedep −blaze-htmldep ~bcryptdep ~bytestringdep ~textnew-uploader

Dependencies removed: aeson, authenticate, blaze-html, blaze-markup, containers, data-default, email-validate, file-embed, hamlet, http-conduit, http-types, lifted-base, mime-mail, network, persistent, persistent-template, pureMD5, pwstore-fast, random, resourcet, safe, shakespeare-css, shakespeare-js, template-haskell, time, transformers, unordered-containers, wai

Dependency ranges changed: bcrypt, bytestring, text, yesod-auth, yesod-persistent

Files

Yesod/Auth/BCrypt.hs view
@@ -10,8 +10,8 @@ {-# LANGUAGE CPP                        #-} ------------------------------------------------------------------------------- -- |--- Module      :  Yesod.Auth.HashDB--- Copyright   :  (c) Patrick Brisbin 2010 +-- Module      :  Yesod.Auth.BCrypt+-- Copyright   :  (c) Patrick Brisbin 2010 -- License     :  as-is -- -- Maintainer  :  pbrisbin@gmail.com@@ -19,7 +19,7 @@ -- Portability :  Portable -- -- A yesod-auth AuthPlugin designed to look users up in Persist where--- their user id's and a Bcrypt hash + salt of their password is stored.+-- their user ID and a Bcrypt hash + salt of their password is stored. -- -- Example usage: --@@ -56,7 +56,7 @@ -- -- --------------------------------------------------------------------------------module Yesod.Auth.HashDB+module Yesod.Auth.BCrypt     ( HashDBUser(..)     , Unique (..)     , setPassword@@ -76,18 +76,14 @@ import Yesod.Form import Yesod.Auth import Yesod.Core-import Text.Hamlet (hamlet)  import Control.Applicative         ((<$>), (<*>))-import Control.Monad               (replicateM,liftM) import Data.Typeable -import qualified Data.ByteString.Lazy.Char8 as LBS (pack, unpack) import qualified Data.ByteString.Char8 as BS (pack, unpack) import Crypto.BCrypt-import Data.Text                   (Text, pack, unpack, append)+import Data.Text                   (Text, pack, unpack) import Data.Maybe                  -import System.Random               (randomRIO) import Prelude -- | Interface for data type which holds user info. It's just a --   collection of getters and setters@@ -104,7 +100,7 @@ saltedHash :: Text              -- ^ Password            -> IO (Maybe Text) saltedHash password = do-   hash <- (hashPasswordUsingPolicy (HashingPolicy 10 "$2y") . BS.pack . unpack) password+   hash <- (hashPasswordUsingPolicy (HashingPolicy 10 "$2y$") . BS.pack . unpack) password    return $ if (isJust hash)                 then Just $ pack $ BS.unpack $ fromJust hash                 else Nothing@@ -114,7 +110,9 @@ setPassword :: (HashDBUser siteuser) => Text -> siteuser -> IO (siteuser) setPassword pwd u = do      hash <- saltedHash pwd-    return $ setSaltAndPasswordHash (fromJust hash) u+    case hash of+        Nothing -> return u+        Just h -> return $ setSaltAndPasswordHash h u   ----------------------------------------------------------------@@ -155,7 +153,7 @@               , PersistUnique (b (HandlerT y IO))               )            => (Text -> Maybe (Unique siteuser))-           -> HandlerT Auth (HandlerT y IO) ()+           -> HandlerT Auth (HandlerT y IO) TypedContent postLoginR uniq = do     (mu,mp) <- lift $ runInputPost $ (,)         <$> iopt textField "username"@@ -164,7 +162,7 @@     isValid <- lift $ fromMaybe (return False)                   (validateUser <$> (uniq =<< mu) <*> mp)     if isValid -       then lift $ setCreds True $ Creds "hashdb" (fromMaybe "" mu) []+       then lift $ setCredsRedirect $ Creds "hashdb" (fromMaybe "" mu) []        else do            tm <- getRouteToParent            lift $ loginErrorMessage (tm LoginR) "Invalid username/password"@@ -195,7 +193,9 @@             case x of                 -- user exists                 Just (Entity uid _) -> return $ Just uid-                Nothing       -> loginErrorMessage (authR LoginR) "User not found"+                Nothing       -> do+                  _ <- loginErrorMessage (authR LoginR) "User not found"+                  return Nothing  -- | Prompt for username and password, validate that against a database --   which holds the username and a hash of the password
yesod-auth-bcrypt.cabal view
@@ -1,5 +1,5 @@ name:            yesod-auth-bcrypt-version:         0.1.0+version:         0.1.1 license:         MIT license-file:    LICENSE author:          Oliver Hunt@@ -14,45 +14,17 @@  library     build-depends:   base                    >= 4         && < 5-                   , authenticate            >= 1.3-                   , bytestring              >= 0.9.1.4+                   , bytestring              >= 0.9.1.4   && < 0.11                    , yesod-core              >= 1.2       && < 1.3-                   , wai                     >= 1.4-                   , template-haskell-                   , pureMD5                 >= 2.0-                   , random                  >= 1.0.0.2-                   , text                    >= 0.7-                   , mime-mail               >= 0.3-                   , yesod-persistent        >= 1.2-                   , hamlet                  >= 1.1       && < 1.2-                   , shakespeare-css         >= 1.0       && < 1.1-                   , shakespeare-js          >= 1.0.2     && < 1.3-                   , containers-                   , unordered-containers+                   , text                    >= 0.7       && < 1.2+                   , yesod-persistent        >= 1.2       && < 1.3                    , yesod-form              >= 1.3       && < 1.4-                   , transformers            >= 0.2.2-                   , persistent              >= 1.2       && < 1.4-                   , persistent-template     >= 1.2       && < 1.4-                   , http-conduit            >= 1.5-                   , aeson                   >= 0.5-                   , pwstore-fast            >= 2.2-                   , lifted-base             >= 0.1-                   , blaze-html              >= 0.5-                   , blaze-markup            >= 0.5.1-                   , network-                   , http-types-                   , file-embed-                   , email-validate          >= 1.0-                   , data-default-                   , resourcet-                   , safe-                   , time-                   , yesod-auth-                   , bcrypt+                   , yesod-auth              >= 1.3       && < 1.4+                   , bcrypt                  >= 0.0.4     && < 0.1      exposed-modules: Yesod.Auth.BCrypt     ghc-options:     -Wall  source-repository head   type:     git-  location: https://github.com/yesodweb/yesod+  location: https://github.com/TobyGoodwin/yesod-auth-bcrypt