mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-07 02:13:50 +02:00
require getCreds method
This commit is contained in:
parent
3457bfd3a0
commit
d966f17704
@ -14,7 +14,7 @@ import Yesod.Auth.OAuth2.Internal
|
|||||||
oauth2Url :: Text -> AuthRoute
|
oauth2Url :: Text -> AuthRoute
|
||||||
oauth2Url name = PluginR name ["forward"]
|
oauth2Url name = PluginR name ["forward"]
|
||||||
|
|
||||||
authOAuth2 name oauth = AuthPlugin name dispatch login
|
authOAuth2 name oauth getCreds = AuthPlugin name dispatch login
|
||||||
where
|
where
|
||||||
url = PluginR name ["callback"]
|
url = PluginR name ["callback"]
|
||||||
dispatch "GET" ["forward"] = do
|
dispatch "GET" ["forward"] = do
|
||||||
@ -26,7 +26,9 @@ authOAuth2 name oauth = AuthPlugin name dispatch login
|
|||||||
dispatch "GET" ["callback"] = do
|
dispatch "GET" ["callback"] = do
|
||||||
code <- lift $ runInputGet $ ireq textField "code"
|
code <- lift $ runInputGet $ ireq textField "code"
|
||||||
mtoken <- liftIO $ postAccessToken oauth (encodeUtf8 code) (Just "authorization_code")
|
mtoken <- liftIO $ postAccessToken oauth (encodeUtf8 code) (Just "authorization_code")
|
||||||
undefined
|
case mtoken of
|
||||||
|
Nothing -> permissionDenied "Couldn't get token"
|
||||||
|
Just token -> getCreds token
|
||||||
disptach _ _ = notFound
|
disptach _ _ = notFound
|
||||||
login tm = do
|
login tm = do
|
||||||
render <- getUrlRender
|
render <- getUrlRender
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user