From 7f4030feda0416242ba840dd295ea69caca51cf8 Mon Sep 17 00:00:00 2001 From: "William R. Arellano" Date: Tue, 31 Oct 2023 11:38:51 -0500 Subject: [PATCH] use case to avoid getParentUrlRender --- src/Yesod/Auth/OAuth2/Dispatch.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Yesod/Auth/OAuth2/Dispatch.hs b/src/Yesod/Auth/OAuth2/Dispatch.hs index a0b8b81..7ded8ca 100644 --- a/src/Yesod/Auth/OAuth2/Dispatch.hs +++ b/src/Yesod/Auth/OAuth2/Dispatch.hs @@ -12,7 +12,6 @@ module Yesod.Auth.OAuth2.Dispatch , dispatchAuthRequest ) where -import Control.Applicative ((<|>)) import Control.Monad (unless) import Control.Monad.Except (MonadError (..)) import Data.Text (Text) @@ -106,11 +105,15 @@ withCallbackAndState -> Text -> m OAuth2 withCallbackAndState name oauth2 csrf = do - uri <- ($ PluginR name ["callback"]) <$> getParentUrlRender - callback <- maybe (throwError $ InvalidCallbackUri uri) pure $ fromText uri + callback <- + case oauth2RedirectUri oauth2 of + Just uri -> pure uri + Nothing -> do + uri <- ($ PluginR name ["callback"]) <$> getParentUrlRender + maybe (throwError $ InvalidCallbackUri uri) pure $ fromText uri pure oauth2 - { oauth2RedirectUri = (oauth2RedirectUri oauth2) <|> Just callback + { oauth2RedirectUri = Just callback , oauth2AuthorizeEndpoint = oauth2AuthorizeEndpoint oauth2 `withQuery` [("state", encodeUtf8 csrf)] }