yesod-form 0.2

This commit is contained in:
Michael Snoyman 2011-05-13 09:01:48 +03:00
parent 4cc7d9c7d3
commit c44ee5509e
7 changed files with 22 additions and 22 deletions

View File

@ -9,7 +9,7 @@ module Yesod.Auth.Dummy
) where
import Yesod.Auth
import Yesod.Form (runFormPost', stringInput)
import Yesod.Form (runInputPost, textField, ireq)
import Yesod.Handler (notFound)
import Text.Hamlet (hamlet)
@ -18,7 +18,7 @@ authDummy =
AuthPlugin "dummy" dispatch login
where
dispatch "POST" [] = do
ident <- runFormPost' $ stringInput "ident"
ident <- runInputPost $ ireq textField "ident"
setCreds True $ Creds "dummy" ident []
dispatch _ _ = notFound
url = PluginR "dummy" []

View File

@ -136,7 +136,7 @@ getRegisterR = do
postRegisterR :: YesodAuthEmail master => GHandler Auth master RepHtml
postRegisterR = do
y <- getYesod
email <- runFormPost' $ emailInput "email"
email <- runInputPost $ ireq emailField "email"
mecreds <- getEmailCreds email
(lid, verKey) <-
case mecreds of
@ -196,9 +196,9 @@ getVerifyR lid key = do
postLoginR :: YesodAuthEmail master => GHandler Auth master ()
postLoginR = do
(email, pass) <- runFormPost' $ (,)
<$> emailInput "email"
<*> stringInput "password"
(email, pass) <- runInputPost $ (,)
<$> ireq emailField "email"
<*> ireq textField "password"
mecreds <- getEmailCreds email
maid <-
case (mecreds >>= emailCredsAuthId, fmap emailCredsStatus mecreds) of
@ -215,7 +215,6 @@ postLoginR = do
Just _aid ->
setCreds True $ Creds "email" email [("verifiedEmail", email)] -- FIXME aid?
Nothing -> do
y <- getYesod
mr <- getMessageRender
setMessage $ mr Msg.InvalidEmailPass
toMaster <- getRouteToMaster
@ -257,9 +256,9 @@ getPasswordR = do
postPasswordR :: YesodAuthEmail master => GHandler Auth master ()
postPasswordR = do
(new, confirm) <- runFormPost' $ (,)
<$> stringInput "new"
<*> stringInput "confirm"
(new, confirm) <- runInputPost $ (,)
<$> ireq textField "new"
<*> ireq textField "confirm"
toMaster <- getRouteToMaster
y <- getYesod
when (new /= confirm) $ do

View File

@ -46,7 +46,7 @@ authFacebook cid secret perms =
render <- getUrlRender
tm <- getRouteToMaster
let fb = Facebook.Facebook cid secret $ render $ tm url
code <- runFormGet' $ stringInput "code"
code <- runInputGet $ ireq textField "code"
at <- liftIO $ Facebook.getAccessToken fb code
let Facebook.AccessToken at' = at
so <- liftIO $ Facebook.getGraphData at "me"

View File

@ -115,9 +115,9 @@ postLoginR :: (YesodAuth y,
PersistBackend (YesodDB y (GGHandler Auth y IO)))
=> GHandler Auth y ()
postLoginR = do
(mu,mp) <- runFormPost' $ (,)
<$> maybeStringInput "username"
<*> maybeStringInput "password"
(mu,mp) <- runInputPost $ (,)
<$> iopt textField "username"
<*> iopt textField "password"
isValid <- case (mu,mp) of
(Nothing, _ ) -> return False

View File

@ -22,6 +22,7 @@ import Data.Text (Text, unpack)
import Data.Text.Encoding (encodeUtf8, decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode)
import Data.ByteString (ByteString)
import Control.Applicative ((<$>), (<*>))
oauthUrl :: Text -> AuthRoute
oauthUrl name = PluginR name ["forward"]
@ -51,8 +52,9 @@ authOAuth name ident reqUrl accUrl authUrl key sec = AuthPlugin name dispatch lo
tok <- liftIO $ getTemporaryCredential oauth'
redirectText RedirectTemporary (fromString $ authorizeUrl oauth' tok)
dispatch "GET" [] = do
verifier <- runFormGet' $ stringInput "oauth_verifier"
oaTok <- runFormGet' $ stringInput "oauth_token"
(verifier, oaTok) <- runInputGet $ (,)
<$> ireq textField "oauth_verifier"
<*> ireq textField "oauth_token"
let reqTok = Credential [ ("oauth_verifier", encodeUtf8 verifier), ("oauth_token", encodeUtf8 oaTok)
]
accTok <- liftIO $ getAccessToken oauth reqTok

View File

@ -56,10 +56,9 @@ authOpenId =
<input type="submit" value="#{mr Msg.LoginOpenID}">
|]
dispatch "GET" ["forward"] = do
(roid, _, _) <- runFormGet $ stringInput name
y <- getYesod
roid <- runInputGet $ iopt textField name
case roid of
FormSuccess oid -> do
Just oid -> do
render <- getUrlRender
toMaster <- getRouteToMaster
let complete' = render $ toMaster complete
@ -71,7 +70,7 @@ authOpenId =
)
(redirectText RedirectTemporary)
res
_ -> do
Nothing -> do
toMaster <- getRouteToMaster
mr <- getMessageRender
setMessage $ mr Msg.NoOpenID

View File

@ -1,5 +1,5 @@
name: yesod-auth
version: 0.5.0
version: 0.6.0
license: BSD3
license-file: LICENSE
author: Michael Snoyman, Patrick Brisbin
@ -34,7 +34,7 @@ library
, hamlet >= 0.8.1 && < 0.9
, yesod-json >= 0.1 && < 0.2
, containers >= 0.2 && < 0.5
, yesod-form >= 0.1 && < 0.2
, yesod-form >= 0.2 && < 0.3
, transformers >= 0.2 && < 0.3
, persistent >= 0.5 && < 0.6
, persistent-template >= 0.5 && < 0.6