From 72c64102b02e56f59e64f5f30da9bd631036c25f Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Wed, 7 Feb 2018 07:52:06 -0800 Subject: [PATCH] Fix BattleNet interface - Incorrect indentation - We should always accept Id/Secret last - The function is oauth... not oAuth... Because of the mis-naming, at least we could fix the argument-order in a backwards-compatible way, deprecating the old function/interface. --- src/Yesod/Auth/OAuth2/BattleNet.hs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Yesod/Auth/OAuth2/BattleNet.hs b/src/Yesod/Auth/OAuth2/BattleNet.hs index 322df1c..f7e3af9 100644 --- a/src/Yesod/Auth/OAuth2/BattleNet.hs +++ b/src/Yesod/Auth/OAuth2/BattleNet.hs @@ -9,8 +9,9 @@ -- * Returns user's battletag in extras. -- module Yesod.Auth.OAuth2.BattleNet - ( oAuth2BattleNet - ) where + ( oauth2BattleNet + , oAuth2BattleNet + ) where import Yesod.Auth.OAuth2.Prelude @@ -26,14 +27,14 @@ instance FromJSON User where pluginName :: Text pluginName = "battle.net" -oAuth2BattleNet +oauth2BattleNet :: YesodAuth m - => Text -- ^ Client ID - -> Text -- ^ Client Secret + => WidgetT m IO () -- ^ Login widget -> Text -- ^ User region (e.g. "eu", "cn", "us") - -> WidgetT m IO () -- ^ Login widget + -> Text -- ^ Client ID + -> Text -- ^ Client Secret -> AuthPlugin m -oAuth2BattleNet clientId clientSecret region widget = +oauth2BattleNet widget region clientId clientSecret = authOAuth2Widget widget pluginName oauth2 $ \manager token -> do (User userId, userResponse) <- authGetProfile pluginName manager token @@ -62,3 +63,7 @@ apiHost region = Host $ encodeUtf8 $ region <> ".api.battle.net" wwwHost :: Text -> Host wwwHost "cn" = "www.battlenet.com.cn" wwwHost region = Host $ encodeUtf8 $ region <> ".battle.net" + +oAuth2BattleNet :: YesodAuth m => Text -> Text -> Text -> WidgetT m IO () -> AuthPlugin m +oAuth2BattleNet i s r w = oauth2BattleNet w r i s +{-# DEPRECATED oAuth2BattleNet "Use oauth2BattleNet" #-}