Fixes #42; slightly nicer error message when no 'code' field.

This commit is contained in:
silky 2015-10-13 15:22:57 +11:00
parent 4afaba6645
commit 348ffd9a01
2 changed files with 14 additions and 11 deletions

View File

@ -102,7 +102,10 @@ authOAuth2Widget widget name oauth getCreds = AuthPlugin name dispatch login
deleteSession tokenSessionKey deleteSession tokenSessionKey
case newToken of case newToken of
Just csrfToken | newToken == oldToken -> do Just csrfToken | newToken == oldToken -> do
code <- lift $ runInputGet $ ireq textField "code" mcode <- lift $ runInputGet $ iopt textField "code"
case mcode of
Nothing -> permissionDenied "`Code` field not provided."
Just code -> do
oauth' <- withCallback csrfToken oauth' <- withCallback csrfToken
master <- lift getYesod master <- lift getYesod
result <- liftIO $ fetchAccessToken (authHttpManager master) oauth' (encodeUtf8 code) result <- liftIO $ fetchAccessToken (authHttpManager master) oauth' (encodeUtf8 code)

View File

@ -1,5 +1,5 @@
name: yesod-auth-oauth2 name: yesod-auth-oauth2
version: 0.1.4 version: 0.1.5
license: BSD3 license: BSD3
license-file: LICENSE license-file: LICENSE
author: Tom Streller author: Tom Streller
@ -52,4 +52,4 @@ library
source-repository head source-repository head
type: git type: git
location: https://github.com/thoughtbot/authenticate-oauth2.git location: https://github.com/thoughtbot/yesod-auth-oauth2.git