mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-10 19:34:56 +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
|
||||
case newToken of
|
||||
Just csrfToken | newToken == oldToken -> do
|
||||
code <- lift $ runInputGet $ ireq textField "code"
|
||||
oauth' <- withCallback csrfToken
|
||||
master <- lift getYesod
|
||||
result <- liftIO $ fetchAccessToken (authHttpManager master) oauth' (encodeUtf8 code)
|
||||
case result of
|
||||
Left _ -> permissionDenied "Unable to retreive OAuth2 token"
|
||||
Right token -> do
|
||||
creds <- liftIO $ getCreds (authHttpManager master) token
|
||||
lift $ setCredsRedirect creds
|
||||
mcode <- lift $ runInputGet $ iopt textField "code"
|
||||
case mcode of
|
||||
Nothing -> permissionDenied "`Code` field not provided."
|
||||
Just code -> do
|
||||
oauth' <- withCallback csrfToken
|
||||
master <- lift getYesod
|
||||
result <- liftIO $ fetchAccessToken (authHttpManager master) oauth' (encodeUtf8 code)
|
||||
case result of
|
||||
Left _ -> permissionDenied "Unable to retreive OAuth2 token"
|
||||
Right token -> do
|
||||
creds <- liftIO $ getCreds (authHttpManager master) token
|
||||
lift $ setCredsRedirect creds
|
||||
_ ->
|
||||
permissionDenied "Invalid OAuth2 state token"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-auth-oauth2
|
||||
version: 0.1.4
|
||||
version: 0.1.5
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Tom Streller
|
||||
@ -52,4 +52,4 @@ library
|
||||
|
||||
source-repository head
|
||||
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