Removed cookie as a parameter type
This commit is contained in:
parent
309757c22d
commit
9ccfe9ba90
@ -26,7 +26,6 @@ import qualified Web.Authenticate.OpenId as OpenId
|
|||||||
import Yesod
|
import Yesod
|
||||||
import Yesod.Constants
|
import Yesod.Constants
|
||||||
|
|
||||||
import Control.Applicative ((<$>))
|
|
||||||
import Control.Monad.Attempt
|
import Control.Monad.Attempt
|
||||||
|
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
@ -114,10 +113,14 @@ authOpenidForward = do
|
|||||||
(redirect RedirectTemporary)
|
(redirect RedirectTemporary)
|
||||||
res
|
res
|
||||||
|
|
||||||
authOpenidComplete :: Handler y HtmlObject
|
authOpenidComplete :: YesodApproot y => Handler y HtmlObject
|
||||||
authOpenidComplete = do
|
authOpenidComplete = do
|
||||||
gets' <- rawGetParams <$> getRawRequest
|
ar <- getApproot
|
||||||
dest <- runRequest $ cookieParam "DEST"
|
rr <- getRawRequest
|
||||||
|
let gets' = rawGetParams rr
|
||||||
|
let dest = case cookies rr "DEST" of
|
||||||
|
[] -> ar
|
||||||
|
(x:_) -> x
|
||||||
res <- runAttemptT $ OpenId.authenticate gets'
|
res <- runAttemptT $ OpenId.authenticate gets'
|
||||||
let onFailure err = redirect RedirectTemporary
|
let onFailure err = redirect RedirectTemporary
|
||||||
$ "/auth/openid/?message="
|
$ "/auth/openid/?message="
|
||||||
@ -125,7 +128,7 @@ authOpenidComplete = do
|
|||||||
let onSuccess (OpenId.Identifier ident) = do
|
let onSuccess (OpenId.Identifier ident) = do
|
||||||
deleteCookie "DEST"
|
deleteCookie "DEST"
|
||||||
header authCookieName ident
|
header authCookieName ident
|
||||||
redirect RedirectTemporary $ fromMaybe "/" dest
|
redirect RedirectTemporary dest
|
||||||
attempt onFailure onSuccess res
|
attempt onFailure onSuccess res
|
||||||
|
|
||||||
rpxnowLogin :: YesodAuth y => Handler y HtmlObject
|
rpxnowLogin :: YesodAuth y => Handler y HtmlObject
|
||||||
|
|||||||
@ -42,14 +42,11 @@ import Data.Convertible.Text
|
|||||||
data ParamType =
|
data ParamType =
|
||||||
GetParam
|
GetParam
|
||||||
| PostParam
|
| PostParam
|
||||||
| CookieParam
|
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
-- | In GET parameters, the key. In cookies, the cookie name. So on and so
|
|
||||||
-- forth.
|
|
||||||
type ParamName = String
|
type ParamName = String
|
||||||
|
|
||||||
-- | The 'String' value of a parameter, such as cookie content.
|
-- | The 'String' value of a parameter.
|
||||||
type ParamValue = String
|
type ParamValue = String
|
||||||
|
|
||||||
-- | Anything which can be converted from a list of 'String's.
|
-- | Anything which can be converted from a list of 'String's.
|
||||||
|
|||||||
@ -26,13 +26,13 @@ module Yesod.Request
|
|||||||
, getParam
|
, getParam
|
||||||
, postParam
|
, postParam
|
||||||
, anyParam
|
, anyParam
|
||||||
, cookieParam
|
|
||||||
, identifier
|
, identifier
|
||||||
, displayName
|
, displayName
|
||||||
, acceptedLanguages
|
, acceptedLanguages
|
||||||
, requestPath
|
, requestPath
|
||||||
, parseEnv
|
, parseEnv
|
||||||
, runRequest
|
, runRequest
|
||||||
|
, cookies
|
||||||
-- * Building actual request
|
-- * Building actual request
|
||||||
, Request (..)
|
, Request (..)
|
||||||
, Hack.RequestMethod (..)
|
, Hack.RequestMethod (..)
|
||||||
@ -130,10 +130,6 @@ postParam = genParam postParams PostParam
|
|||||||
anyParam :: (Parameter a) => ParamName -> Request a
|
anyParam :: (Parameter a) => ParamName -> Request a
|
||||||
anyParam = genParam anyParams PostParam -- FIXME
|
anyParam = genParam anyParams PostParam -- FIXME
|
||||||
|
|
||||||
-- | Parse a value passed as a raw cookie.
|
|
||||||
cookieParam :: (Parameter a) => ParamName -> Request a
|
|
||||||
cookieParam = genParam cookies CookieParam
|
|
||||||
|
|
||||||
-- | Extract the cookie which specifies the identifier for a logged in
|
-- | Extract the cookie which specifies the identifier for a logged in
|
||||||
-- user, if available.
|
-- user, if available.
|
||||||
identifier :: (Functor m, Monad m, RequestReader m) => m (Maybe String)
|
identifier :: (Functor m, Monad m, RequestReader m) => m (Maybe String)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user