From ce98f1ba4e7dd713377506ddc8bcd47624e6f1a9 Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Sun, 28 Jun 2015 18:15:25 +0200 Subject: [PATCH] got rid of maybe --- Yesod/Auth/OAuth2.hs | 9 +++------ Yesod/Auth/OAuth2/EveOnline.hs | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Yesod/Auth/OAuth2.hs b/Yesod/Auth/OAuth2.hs index fe91915..0f203d0 100644 --- a/Yesod/Auth/OAuth2.hs +++ b/Yesod/Auth/OAuth2.hs @@ -59,7 +59,7 @@ authOAuth2 :: YesodAuth m -- -- See @'fromProfileURL'@ for an example. -> AuthPlugin m -authOAuth2 name oauth getCreds = authOAuth2Widget name oauth getCreds Nothing +authOAuth2 name oauth getCreds = authOAuth2Widget name oauth getCreds [whamlet|Login via #{name}|] authOAuth2Widget :: YesodAuth m => Text -- ^ Service name @@ -71,7 +71,7 @@ authOAuth2Widget :: YesodAuth m -- second authorized request to @api/me.json@. -- -- See @'fromProfileURL'@ for an example. - -> Maybe (WidgetT m IO ()) -- ^ Widget to be shown instead of "Login with xxx"-Text + -> WidgetT m IO () -- ^ Widget to be shown instead of "Login with xxx"-Text -> AuthPlugin m authOAuth2Widget name oauth getCreds widget = AuthPlugin name dispatch login @@ -120,10 +120,7 @@ authOAuth2Widget name oauth getCreds widget = AuthPlugin name dispatch login login tm = [whamlet| - $maybe w <- widget - ^{w} - $nothing - Login via #{name} + ^{widget} |] -- | Handle the common case of fetching Profile information a JSON endpoint diff --git a/Yesod/Auth/OAuth2/EveOnline.hs b/Yesod/Auth/OAuth2/EveOnline.hs index 219511e..29683af 100644 --- a/Yesod/Auth/OAuth2/EveOnline.hs +++ b/Yesod/Auth/OAuth2/EveOnline.hs @@ -88,7 +88,10 @@ oauth2EveScoped :: YesodAuth m -> [Text] -- ^ List of scopes to request -> Maybe (WidgetT m IO ()) -- ^ Login-Widget -> AuthPlugin m -oauth2EveScoped clientId clientSecret scopes = authOAuth2Widget "eveonline" oauth fetchEveProfile +oauth2EveScoped clientId clientSecret scopes widget = + case widget of + Just w -> authOAuth2Widget "eveonline" oauth fetchEveProfile w + Nothing -> authOAuth2 "eveonline" oauth fetchEveProfile where oauth = OAuth2 { oauthClientId = encodeUtf8 clientId