Migrate to yesod-core 0.7
This commit is contained in:
parent
16a23f4625
commit
1cae68debc
@ -21,10 +21,22 @@ module Yesod.Helpers.Auth
|
|||||||
, requireAuth
|
, requireAuth
|
||||||
) where
|
) 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 Language.Haskell.TH.Syntax hiding (lift)
|
||||||
import qualified Data.ByteString.Char8 as S8
|
import qualified Data.ByteString.Char8 as S8
|
||||||
import qualified Network.Wai as W
|
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
|
data Auth = Auth
|
||||||
|
|
||||||
@ -141,8 +153,10 @@ $nothing
|
|||||||
%p Not logged in.
|
%p Not logged in.
|
||||||
|]
|
|]
|
||||||
json creds =
|
json creds =
|
||||||
jsonMap
|
ValueObject $ Map.fromList
|
||||||
[ ("logged_in", jsonScalar $ maybe "false" (const "true") creds)
|
[ (pack "logged_in"
|
||||||
|
, ValueAtom $ AtomBoolean
|
||||||
|
$ maybe False (const True) creds)
|
||||||
]
|
]
|
||||||
|
|
||||||
getLoginR :: YesodAuth m => GHandler Auth m RepHtml
|
getLoginR :: YesodAuth m => GHandler Auth m RepHtml
|
||||||
|
|||||||
@ -7,8 +7,10 @@ module Yesod.Helpers.Auth.Dummy
|
|||||||
( authDummy
|
( authDummy
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Yesod
|
|
||||||
import Yesod.Helpers.Auth
|
import Yesod.Helpers.Auth
|
||||||
|
import Yesod.Form (runFormPost', stringInput)
|
||||||
|
import Yesod.Handler (notFound)
|
||||||
|
import Text.Hamlet (hamlet)
|
||||||
|
|
||||||
authDummy :: YesodAuth m => AuthPlugin m
|
authDummy :: YesodAuth m => AuthPlugin m
|
||||||
authDummy =
|
authDummy =
|
||||||
|
|||||||
@ -7,7 +7,6 @@ module Yesod.Helpers.Auth.Email
|
|||||||
, saltPass
|
, saltPass
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Yesod
|
|
||||||
import Network.Mail.Mime (randomString)
|
import Network.Mail.Mime (randomString)
|
||||||
import Yesod.Helpers.Auth
|
import Yesod.Helpers.Auth
|
||||||
import System.Random
|
import System.Random
|
||||||
@ -17,6 +16,15 @@ import Data.Digest.Pure.MD5
|
|||||||
import qualified Data.Text.Lazy as T
|
import qualified Data.Text.Lazy as T
|
||||||
import Data.Text.Lazy.Encoding (encodeUtf8)
|
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, register, setpass :: AuthRoute
|
||||||
login = PluginR "email" ["login"]
|
login = PluginR "email" ["login"]
|
||||||
register = PluginR "email" ["register"]
|
register = PluginR "email" ["register"]
|
||||||
|
|||||||
@ -5,12 +5,17 @@ module Yesod.Helpers.Auth.Facebook
|
|||||||
, facebookUrl
|
, facebookUrl
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Yesod
|
|
||||||
import Yesod.Helpers.Auth
|
import Yesod.Helpers.Auth
|
||||||
import qualified Web.Authenticate.Facebook as Facebook
|
import qualified Web.Authenticate.Facebook as Facebook
|
||||||
import Data.Object (fromMapping, lookupScalar)
|
import Data.Object (fromMapping, lookupScalar)
|
||||||
import Data.Maybe (fromMaybe)
|
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 :: AuthRoute
|
||||||
facebookUrl = PluginR "facebook" ["forward"]
|
facebookUrl = PluginR "facebook" ["forward"]
|
||||||
|
|
||||||
|
|||||||
@ -5,11 +5,19 @@ module Yesod.Helpers.Auth.OpenId
|
|||||||
, forwardUrl
|
, forwardUrl
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Yesod
|
|
||||||
import Yesod.Helpers.Auth
|
import Yesod.Helpers.Auth
|
||||||
import qualified Web.Authenticate.OpenId as OpenId
|
import qualified Web.Authenticate.OpenId as OpenId
|
||||||
import Control.Monad.Attempt
|
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 :: AuthRoute
|
||||||
forwardUrl = PluginR "openid" ["forward"]
|
forwardUrl = PluginR "openid" ["forward"]
|
||||||
|
|
||||||
@ -49,7 +57,7 @@ authOpenId =
|
|||||||
render <- getUrlRender
|
render <- getUrlRender
|
||||||
toMaster <- getRouteToMaster
|
toMaster <- getRouteToMaster
|
||||||
let complete' = render $ toMaster complete
|
let complete' = render $ toMaster complete
|
||||||
res <- runAttemptT $ OpenId.getForwardUrl oid complete'
|
res <- runAttemptT $ OpenId.getForwardUrl oid complete' Nothing []
|
||||||
attempt
|
attempt
|
||||||
(\err -> do
|
(\err -> do
|
||||||
setMessage $ string $ show err
|
setMessage $ string $ show err
|
||||||
@ -77,6 +85,6 @@ completeHelper gets' = do
|
|||||||
let onFailure err = do
|
let onFailure err = do
|
||||||
setMessage $ string $ show err
|
setMessage $ string $ show err
|
||||||
redirect RedirectTemporary $ toMaster LoginR
|
redirect RedirectTemporary $ toMaster LoginR
|
||||||
let onSuccess (OpenId.Identifier ident) =
|
let onSuccess (OpenId.Identifier ident, _) =
|
||||||
setCreds True $ Creds "openid" ident []
|
setCreds True $ Creds "openid" ident []
|
||||||
attempt onFailure onSuccess res
|
attempt onFailure onSuccess res
|
||||||
|
|||||||
@ -4,11 +4,16 @@ module Yesod.Helpers.Auth.Rpxnow
|
|||||||
( authRpxnow
|
( authRpxnow
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Yesod
|
|
||||||
import Yesod.Helpers.Auth
|
import Yesod.Helpers.Auth
|
||||||
import qualified Web.Authenticate.Rpxnow as Rpxnow
|
import qualified Web.Authenticate.Rpxnow as Rpxnow
|
||||||
import Control.Monad (mplus)
|
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
|
authRpxnow :: YesodAuth m
|
||||||
=> String -- ^ app name
|
=> String -- ^ app name
|
||||||
-> String -- ^ key
|
-> String -- ^ key
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
name: yesod-auth
|
name: yesod-auth
|
||||||
version: 0.2.0.3
|
version: 0.3.0
|
||||||
license: BSD3
|
license: BSD3
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
maintainer: Michael Snoyman <michael@snoyman.com>
|
maintainer: Michael Snoyman <michael@snoyman.com>
|
||||||
synopsis: Authentication for Yesod.
|
synopsis: Authentication for Yesod.
|
||||||
category: Web
|
category: Web, Yesod
|
||||||
stability: Stable
|
stability: Stable
|
||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.6
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
@ -19,17 +19,26 @@ library
|
|||||||
cpp-options: -DGHC7
|
cpp-options: -DGHC7
|
||||||
else
|
else
|
||||||
build-depends: base >= 4 && < 4.3
|
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
|
, bytestring >= 0.9.1.4 && < 0.10
|
||||||
, yesod >= 0.6 && < 0.7
|
, yesod-core >= 0.7 && < 0.8
|
||||||
, wai >= 0.2 && < 0.3
|
, wai >= 0.3 && < 0.4
|
||||||
, template-haskell
|
, template-haskell
|
||||||
, pureMD5 >= 1.1 && < 2.2
|
, pureMD5 >= 1.1 && < 2.2
|
||||||
, random >= 1.0 && < 1.1
|
, random >= 1.0 && < 1.1
|
||||||
, data-object >= 0.3.1.3 && < 0.4
|
, data-object >= 0.3.1.3 && < 0.4
|
||||||
, control-monad-attempt >= 0.3.0 && < 0.4
|
, control-monad-attempt >= 0.3.0 && < 0.4
|
||||||
, text >= 0.7 && < 0.12
|
, 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
|
exposed-modules: Yesod.Helpers.Auth
|
||||||
Yesod.Helpers.Auth.Dummy
|
Yesod.Helpers.Auth.Dummy
|
||||||
Yesod.Helpers.Auth.Email
|
Yesod.Helpers.Auth.Email
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user