authPlugins takes master site as argument (#233)

This commit is contained in:
Michael Snoyman 2012-01-22 20:41:11 +02:00
parent e6577832b4
commit adecd25bc3
2 changed files with 6 additions and 4 deletions

View File

@ -92,14 +92,15 @@ class (Yesod m, PathPiece (AuthId m), RenderMessage m FormMessage) => YesodAuth
getAuthId :: Creds m -> GHandler s m (Maybe (AuthId m))
-- | Which authentication backends to use.
authPlugins :: [AuthPlugin m]
authPlugins :: m -> [AuthPlugin m]
-- | What to show on the login page.
loginHandler :: GHandler Auth m RepHtml
loginHandler = defaultLayout $ do
setTitleI Msg.LoginTitle
tm <- lift getRouteToMaster
mapM_ (flip apLogin tm) authPlugins
master <- lift getYesod
mapM_ (flip apLogin tm) (authPlugins master)
-- | Used for i18n of messages provided by this package.
renderAuthMessage :: m
@ -200,9 +201,10 @@ postLogoutR = do
handlePluginR :: YesodAuth m => Text -> [Text] -> GHandler Auth m ()
handlePluginR plugin pieces = do
master <- getYesod
env <- waiRequest
let method = decodeUtf8With lenientDecode $ W.requestMethod env
case filter (\x -> apName x == plugin) authPlugins of
case filter (\x -> apName x == plugin) (authPlugins master) of
[] -> notFound
ap:_ -> apDispatch ap method pieces

View File

@ -150,7 +150,7 @@ instance YesodAuth ~sitearg~ where
fmap Just $ insert $ User (credsIdent creds) Nothing
-- You can add other plugins like BrowserID, email or OAuth here
authPlugins = [authBrowserId, authGoogleEmail]
authPlugins _ = [authBrowserId, authGoogleEmail]
authHttpManager = httpManager