mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-01-11 19:58:28 +01:00
got rid of maybe
This commit is contained in:
parent
77db081d6c
commit
ce98f1ba4e
@ -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|
|
||||
<a href=@{tm $ oauth2Url name}>
|
||||
$maybe w <- widget
|
||||
^{w}
|
||||
$nothing
|
||||
Login via #{name}
|
||||
^{widget}
|
||||
|]
|
||||
|
||||
-- | Handle the common case of fetching Profile information a JSON endpoint
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user