diff --git a/Yesod/Helpers/Auth.hs b/Yesod/Helpers/Auth.hs index 55451476..480ee16b 100644 --- a/Yesod/Helpers/Auth.hs +++ b/Yesod/Helpers/Auth.hs @@ -21,10 +21,22 @@ module Yesod.Helpers.Auth , requireAuth ) where -import Yesod +import Yesod.Handler +import Yesod.Core +import Yesod.Widget +import Yesod.Content +import Yesod.Dispatch +import Yesod.Persist +import Yesod.Request +import Yesod.Json +import Text.Blaze import Language.Haskell.TH.Syntax hiding (lift) import qualified Data.ByteString.Char8 as S8 import qualified Network.Wai as W +import Text.Hamlet (hamlet) +import Data.Text.Lazy (pack) +import Data.JSON.Types (Value (..), Atom (AtomBoolean)) +import qualified Data.Map as Map data Auth = Auth @@ -141,8 +153,10 @@ $nothing %p Not logged in. |] json creds = - jsonMap - [ ("logged_in", jsonScalar $ maybe "false" (const "true") creds) + ValueObject $ Map.fromList + [ (pack "logged_in" + , ValueAtom $ AtomBoolean + $ maybe False (const True) creds) ] getLoginR :: YesodAuth m => GHandler Auth m RepHtml diff --git a/Yesod/Helpers/Auth/Dummy.hs b/Yesod/Helpers/Auth/Dummy.hs index 7fbfec90..63cc92de 100644 --- a/Yesod/Helpers/Auth/Dummy.hs +++ b/Yesod/Helpers/Auth/Dummy.hs @@ -7,8 +7,10 @@ module Yesod.Helpers.Auth.Dummy ( authDummy ) where -import Yesod import Yesod.Helpers.Auth +import Yesod.Form (runFormPost', stringInput) +import Yesod.Handler (notFound) +import Text.Hamlet (hamlet) authDummy :: YesodAuth m => AuthPlugin m authDummy = diff --git a/Yesod/Helpers/Auth/Email.hs b/Yesod/Helpers/Auth/Email.hs index 754b1d6b..9cbd8b97 100644 --- a/Yesod/Helpers/Auth/Email.hs +++ b/Yesod/Helpers/Auth/Email.hs @@ -7,7 +7,6 @@ module Yesod.Helpers.Auth.Email , saltPass ) where -import Yesod import Network.Mail.Mime (randomString) import Yesod.Helpers.Auth import System.Random @@ -17,6 +16,15 @@ import Data.Digest.Pure.MD5 import qualified Data.Text.Lazy as T import Data.Text.Lazy.Encoding (encodeUtf8) +import Yesod.Form +import Yesod.Handler +import Yesod.Content +import Yesod.Widget +import Yesod.Core +import Text.Hamlet (hamlet) +import Text.Blaze (string) +import Control.Monad.IO.Class (liftIO) + login, register, setpass :: AuthRoute login = PluginR "email" ["login"] register = PluginR "email" ["register"] diff --git a/Yesod/Helpers/Auth/Facebook.hs b/Yesod/Helpers/Auth/Facebook.hs index 5f3e9aad..07ebfd9d 100644 --- a/Yesod/Helpers/Auth/Facebook.hs +++ b/Yesod/Helpers/Auth/Facebook.hs @@ -5,12 +5,17 @@ module Yesod.Helpers.Auth.Facebook , facebookUrl ) where -import Yesod import Yesod.Helpers.Auth import qualified Web.Authenticate.Facebook as Facebook import Data.Object (fromMapping, lookupScalar) import Data.Maybe (fromMaybe) +import Yesod.Form +import Yesod.Handler +import Yesod.Widget +import Text.Hamlet (hamlet) +import Control.Monad.IO.Class (liftIO) + facebookUrl :: AuthRoute facebookUrl = PluginR "facebook" ["forward"] diff --git a/Yesod/Helpers/Auth/OpenId.hs b/Yesod/Helpers/Auth/OpenId.hs index abc73c8e..cfbc949b 100644 --- a/Yesod/Helpers/Auth/OpenId.hs +++ b/Yesod/Helpers/Auth/OpenId.hs @@ -5,11 +5,19 @@ module Yesod.Helpers.Auth.OpenId , forwardUrl ) where -import Yesod import Yesod.Helpers.Auth import qualified Web.Authenticate.OpenId as OpenId import Control.Monad.Attempt +import Yesod.Form +import Yesod.Handler +import Yesod.Widget +import Yesod.Request +import Text.Hamlet (hamlet) +import Text.Cassius (cassius) +import Text.Blaze (string) +import Control.Monad.IO.Class (liftIO) + forwardUrl :: AuthRoute forwardUrl = PluginR "openid" ["forward"] @@ -49,7 +57,7 @@ authOpenId = render <- getUrlRender toMaster <- getRouteToMaster let complete' = render $ toMaster complete - res <- runAttemptT $ OpenId.getForwardUrl oid complete' + res <- runAttemptT $ OpenId.getForwardUrl oid complete' Nothing [] attempt (\err -> do setMessage $ string $ show err @@ -77,6 +85,6 @@ completeHelper gets' = do let onFailure err = do setMessage $ string $ show err redirect RedirectTemporary $ toMaster LoginR - let onSuccess (OpenId.Identifier ident) = + let onSuccess (OpenId.Identifier ident, _) = setCreds True $ Creds "openid" ident [] attempt onFailure onSuccess res diff --git a/Yesod/Helpers/Auth/Rpxnow.hs b/Yesod/Helpers/Auth/Rpxnow.hs index 8b6c887f..defe0211 100644 --- a/Yesod/Helpers/Auth/Rpxnow.hs +++ b/Yesod/Helpers/Auth/Rpxnow.hs @@ -4,11 +4,16 @@ module Yesod.Helpers.Auth.Rpxnow ( authRpxnow ) where -import Yesod import Yesod.Helpers.Auth import qualified Web.Authenticate.Rpxnow as Rpxnow import Control.Monad (mplus) +import Yesod.Handler +import Yesod.Widget +import Yesod.Request +import Text.Hamlet (hamlet) +import Control.Monad.IO.Class (liftIO) + authRpxnow :: YesodAuth m => String -- ^ app name -> String -- ^ key diff --git a/yesod-auth.cabal b/yesod-auth.cabal index df45e1b7..c2a9fc55 100644 --- a/yesod-auth.cabal +++ b/yesod-auth.cabal @@ -1,11 +1,11 @@ name: yesod-auth -version: 0.2.0.3 +version: 0.3.0 license: BSD3 license-file: LICENSE author: Michael Snoyman maintainer: Michael Snoyman synopsis: Authentication for Yesod. -category: Web +category: Web, Yesod stability: Stable cabal-version: >= 1.6 build-type: Simple @@ -19,17 +19,26 @@ library cpp-options: -DGHC7 else build-depends: base >= 4 && < 4.3 - build-depends: authenticate >= 0.7 && < 0.8 + build-depends: authenticate >= 0.8 && < 0.9 , bytestring >= 0.9.1.4 && < 0.10 - , yesod >= 0.6 && < 0.7 - , wai >= 0.2 && < 0.3 + , yesod-core >= 0.7 && < 0.8 + , wai >= 0.3 && < 0.4 , template-haskell , pureMD5 >= 1.1 && < 2.2 , random >= 1.0 && < 1.1 , data-object >= 0.3.1.3 && < 0.4 , control-monad-attempt >= 0.3.0 && < 0.4 , text >= 0.7 && < 0.12 - , mime-mail >= 0.0 && < 0.1 + , mime-mail >= 0.1 && < 0.2 + , blaze-html >= 0.3.0.4 && < 0.4 + , yesod-persistent >= 0.0 && < 0.1 + , hamlet >= 0.7 && < 0.8 + , yesod-json >= 0.0 && < 0.1 + , containers >= 0.2 && < 0.5 + , json-types >= 0.1 && < 0.2 + , text >= 0.11 && < 0.12 + , yesod-form >= 0.0 && < 0.1 + , transformers >= 0.2 && < 0.3 exposed-modules: Yesod.Helpers.Auth Yesod.Helpers.Auth.Dummy Yesod.Helpers.Auth.Email