Migrate to yesod-core 0.7
This commit is contained in:
parent
16a23f4625
commit
1cae68debc
@ -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
|
||||
|
||||
@ -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 =
|
||||
|
||||
@ -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"]
|
||||
|
||||
@ -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"]
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
name: yesod-auth
|
||||
version: 0.2.0.3
|
||||
version: 0.3.0
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
maintainer: Michael Snoyman <michael@snoyman.com>
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user