mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-04-21 10:17:43 +02:00
In-line errLeft
This commit is contained in:
parent
65694e10d7
commit
0f09dd1d05
@ -86,18 +86,13 @@ dispatchCallback name oauth2 getToken getCreds = do
|
|||||||
code <- requireGetParam "code"
|
code <- requireGetParam "code"
|
||||||
manager <- authHttpManager
|
manager <- authHttpManager
|
||||||
oauth2' <- withCallbackAndState name oauth2 csrf
|
oauth2' <- withCallbackAndState name oauth2 csrf
|
||||||
token <-
|
token <- either (throwError . OAuth2ResultError) pure
|
||||||
errLeft OAuth2ResultError $ getToken manager oauth2' $ ExchangeToken
|
=<< liftIO (getToken manager oauth2' $ ExchangeToken code)
|
||||||
code
|
|
||||||
creds <-
|
creds <-
|
||||||
liftIO (getCreds manager token)
|
liftIO (getCreds manager token)
|
||||||
`catch` (throwError . FetchCredsIOException)
|
`catch` (throwError . FetchCredsIOException)
|
||||||
`catch` (throwError . FetchCredsYesodOAuth2Exception)
|
`catch` (throwError . FetchCredsYesodOAuth2Exception)
|
||||||
setCredsRedirect creds
|
setCredsRedirect creds
|
||||||
where
|
|
||||||
errLeft
|
|
||||||
:: (MonadIO m, MonadError e m) => (e' -> e) -> IO (Either e' a) -> m a
|
|
||||||
errLeft f = either (throwError . f) pure <=< liftIO
|
|
||||||
|
|
||||||
withCallbackAndState
|
withCallbackAndState
|
||||||
:: (MonadError DispatchError m, MonadAuthHandler site m)
|
:: (MonadError DispatchError m, MonadAuthHandler site m)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user