diff --git a/Yesod/Auth/OAuth2/Github.hs b/Yesod/Auth/OAuth2/Github.hs index 018a33e..7a50055 100644 --- a/Yesod/Auth/OAuth2/Github.hs +++ b/Yesod/Auth/OAuth2/Github.hs @@ -67,7 +67,7 @@ oauth2GithubScoped :: YesodAuth m -> Text -- ^ Client Secret -> [Text] -- ^ List of scopes to request -> AuthPlugin m -oauth2GithubScoped clientId clientSecret scopes = basicPlugin -- {apDispatch = dispatch} +oauth2GithubScoped clientId clientSecret scopes = authOAuth2 "github" oauth fetchGithubProfile where oauth = OAuth2 { oauthClientId = encodeUtf8 clientId @@ -77,28 +77,6 @@ oauth2GithubScoped clientId clientSecret scopes = basicPlugin -- {apDispatch = d , oauthCallback = Nothing } - -- withState state = authOAuth2 "github" - -- (oauth {oauthOAuthorizeEndpoint = oauthOAuthorizeEndpoint oauth `BS.append` "&state=" `BS.append` encodeUtf8 state}) - -- fetchGithubProfile - - basicPlugin = authOAuth2 "github" oauth fetchGithubProfile - - -- dispatch "GET" ["forward"] = do - -- state <- liftIO $ fmap (T.pack . toString) nextRandom - -- setSession "githubState" state - -- apDispatch (withState state) "GET" ["forward"] - - -- dispatch "GET" ["callback"] = do - -- state <- lift $ runInputGet $ ireq textField "state" - -- savedState <- lookupSession "githubState" - -- _ <- apDispatch basicPlugin "GET" ["callback"] - -- case savedState of - -- Just saved | saved == state -> apDispatch basicPlugin "GET" ["callback"] - -- Just saved -> invalidArgs ["state: " `mappend` state `mappend` ", and not: " `mappend` saved] - -- _ -> invalidArgs ["state: " `mappend` state] - - -- dispatch method ps = apDispatch basicPlugin method ps - fetchGithubProfile :: Manager -> AccessToken -> IO (Creds m) fetchGithubProfile manager token = do userResult <- authGetJSON manager token "https://api.github.com/user"