mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-01-12 04:08:30 +01:00
In-line tryFetchCreds
This commit is contained in:
parent
b6f1a70e5d
commit
abb0ab557a
@ -89,19 +89,16 @@ dispatchCallback name oauth2 getToken getCreds = do
|
||||
token <-
|
||||
errLeft OAuth2ResultError $ getToken manager oauth2' $ ExchangeToken
|
||||
code
|
||||
creds <- errLeft id $ tryFetchCreds $ getCreds manager token
|
||||
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
|
||||
|
||||
tryFetchCreds :: IO a -> IO (Either DispatchError a)
|
||||
tryFetchCreds f =
|
||||
(Right <$> f)
|
||||
`catch` (pure . Left . FetchCredsIOException)
|
||||
`catch` (pure . Left . FetchCredsYesodOAuth2Exception)
|
||||
|
||||
withCallbackAndState
|
||||
:: (MonadError DispatchError m, MonadAuthHandler site m)
|
||||
=> Text
|
||||
|
||||
Loading…
Reference in New Issue
Block a user