authPlugins takes master site as argument (#233)
This commit is contained in:
parent
e6577832b4
commit
adecd25bc3
@ -92,14 +92,15 @@ class (Yesod m, PathPiece (AuthId m), RenderMessage m FormMessage) => YesodAuth
|
|||||||
getAuthId :: Creds m -> GHandler s m (Maybe (AuthId m))
|
getAuthId :: Creds m -> GHandler s m (Maybe (AuthId m))
|
||||||
|
|
||||||
-- | Which authentication backends to use.
|
-- | Which authentication backends to use.
|
||||||
authPlugins :: [AuthPlugin m]
|
authPlugins :: m -> [AuthPlugin m]
|
||||||
|
|
||||||
-- | What to show on the login page.
|
-- | What to show on the login page.
|
||||||
loginHandler :: GHandler Auth m RepHtml
|
loginHandler :: GHandler Auth m RepHtml
|
||||||
loginHandler = defaultLayout $ do
|
loginHandler = defaultLayout $ do
|
||||||
setTitleI Msg.LoginTitle
|
setTitleI Msg.LoginTitle
|
||||||
tm <- lift getRouteToMaster
|
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.
|
-- | Used for i18n of messages provided by this package.
|
||||||
renderAuthMessage :: m
|
renderAuthMessage :: m
|
||||||
@ -200,9 +201,10 @@ postLogoutR = do
|
|||||||
|
|
||||||
handlePluginR :: YesodAuth m => Text -> [Text] -> GHandler Auth m ()
|
handlePluginR :: YesodAuth m => Text -> [Text] -> GHandler Auth m ()
|
||||||
handlePluginR plugin pieces = do
|
handlePluginR plugin pieces = do
|
||||||
|
master <- getYesod
|
||||||
env <- waiRequest
|
env <- waiRequest
|
||||||
let method = decodeUtf8With lenientDecode $ W.requestMethod env
|
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
|
[] -> notFound
|
||||||
ap:_ -> apDispatch ap method pieces
|
ap:_ -> apDispatch ap method pieces
|
||||||
|
|
||||||
|
|||||||
@ -150,7 +150,7 @@ instance YesodAuth ~sitearg~ where
|
|||||||
fmap Just $ insert $ User (credsIdent creds) Nothing
|
fmap Just $ insert $ User (credsIdent creds) Nothing
|
||||||
|
|
||||||
-- You can add other plugins like BrowserID, email or OAuth here
|
-- You can add other plugins like BrowserID, email or OAuth here
|
||||||
authPlugins = [authBrowserId, authGoogleEmail]
|
authPlugins _ = [authBrowserId, authGoogleEmail]
|
||||||
|
|
||||||
authHttpManager = httpManager
|
authHttpManager = httpManager
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user