mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-04-27 05:07:44 +02:00
use case to avoid getParentUrlRender
This commit is contained in:
parent
d379afc54b
commit
7f4030feda
@ -12,7 +12,6 @@ module Yesod.Auth.OAuth2.Dispatch
|
|||||||
, dispatchAuthRequest
|
, dispatchAuthRequest
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative ((<|>))
|
|
||||||
import Control.Monad (unless)
|
import Control.Monad (unless)
|
||||||
import Control.Monad.Except (MonadError (..))
|
import Control.Monad.Except (MonadError (..))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
@ -106,11 +105,15 @@ withCallbackAndState
|
|||||||
-> Text
|
-> Text
|
||||||
-> m OAuth2
|
-> m OAuth2
|
||||||
withCallbackAndState name oauth2 csrf = do
|
withCallbackAndState name oauth2 csrf = do
|
||||||
uri <- ($ PluginR name ["callback"]) <$> getParentUrlRender
|
callback <-
|
||||||
callback <- maybe (throwError $ InvalidCallbackUri uri) pure $ fromText uri
|
case oauth2RedirectUri oauth2 of
|
||||||
|
Just uri -> pure uri
|
||||||
|
Nothing -> do
|
||||||
|
uri <- ($ PluginR name ["callback"]) <$> getParentUrlRender
|
||||||
|
maybe (throwError $ InvalidCallbackUri uri) pure $ fromText uri
|
||||||
pure
|
pure
|
||||||
oauth2
|
oauth2
|
||||||
{ oauth2RedirectUri = (oauth2RedirectUri oauth2) <|> Just callback
|
{ oauth2RedirectUri = Just callback
|
||||||
, oauth2AuthorizeEndpoint =
|
, oauth2AuthorizeEndpoint =
|
||||||
oauth2AuthorizeEndpoint oauth2 `withQuery` [("state", encodeUtf8 csrf)]
|
oauth2AuthorizeEndpoint oauth2 `withQuery` [("state", encodeUtf8 csrf)]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user