mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-01-12 04:08:30 +01:00
In-line errLeft
This commit is contained in:
parent
2d45a24e72
commit
fee13fe23c
@ -86,18 +86,13 @@ dispatchCallback name oauth2 getToken getCreds = do
|
||||
code <- requireGetParam "code"
|
||||
manager <- authHttpManager
|
||||
oauth2' <- withCallbackAndState name oauth2 csrf
|
||||
token <-
|
||||
errLeft OAuth2ResultError $ getToken manager oauth2' $ ExchangeToken
|
||||
code
|
||||
token <- either (throwError . OAuth2ResultError) pure
|
||||
=<< liftIO (getToken manager oauth2' $ ExchangeToken code)
|
||||
creds <-
|
||||
liftIO (getCreds manager token)
|
||||
`catch` (throwError . FetchCredsIOException)
|
||||
`catch` (throwError . FetchCredsYesodOAuth2Exception)
|
||||
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
|
||||
:: (MonadError DispatchError m, MonadAuthHandler site m)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user