mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-11 03:44:57 +02:00
Fixes #42; slightly nicer error message when no 'code' field.
This commit is contained in:
parent
4afaba6645
commit
348ffd9a01
@ -102,15 +102,18 @@ 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"
|
||||||
oauth' <- withCallback csrfToken
|
case mcode of
|
||||||
master <- lift getYesod
|
Nothing -> permissionDenied "`Code` field not provided."
|
||||||
result <- liftIO $ fetchAccessToken (authHttpManager master) oauth' (encodeUtf8 code)
|
Just code -> do
|
||||||
case result of
|
oauth' <- withCallback csrfToken
|
||||||
Left _ -> permissionDenied "Unable to retreive OAuth2 token"
|
master <- lift getYesod
|
||||||
Right token -> do
|
result <- liftIO $ fetchAccessToken (authHttpManager master) oauth' (encodeUtf8 code)
|
||||||
creds <- liftIO $ getCreds (authHttpManager master) token
|
case result of
|
||||||
lift $ setCredsRedirect creds
|
Left _ -> permissionDenied "Unable to retreive OAuth2 token"
|
||||||
|
Right token -> do
|
||||||
|
creds <- liftIO $ getCreds (authHttpManager master) token
|
||||||
|
lift $ setCredsRedirect creds
|
||||||
_ ->
|
_ ->
|
||||||
permissionDenied "Invalid OAuth2 state token"
|
permissionDenied "Invalid OAuth2 state token"
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user