mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-04-22 02:37:43 +02: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.
|
-- See @'fromProfileURL'@ for an example.
|
||||||
-> AuthPlugin m
|
-> 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
|
authOAuth2Widget :: YesodAuth m
|
||||||
=> Text -- ^ Service name
|
=> Text -- ^ Service name
|
||||||
@ -71,7 +71,7 @@ authOAuth2Widget :: YesodAuth m
|
|||||||
-- second authorized request to @api/me.json@.
|
-- second authorized request to @api/me.json@.
|
||||||
--
|
--
|
||||||
-- See @'fromProfileURL'@ for an example.
|
-- 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
|
-> AuthPlugin m
|
||||||
authOAuth2Widget name oauth getCreds widget = AuthPlugin name dispatch login
|
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|
|
login tm = [whamlet|
|
||||||
<a href=@{tm $ oauth2Url name}>
|
<a href=@{tm $ oauth2Url name}>
|
||||||
$maybe w <- widget
|
^{widget}
|
||||||
^{w}
|
|
||||||
$nothing
|
|
||||||
Login via #{name}
|
|
||||||
|]
|
|]
|
||||||
|
|
||||||
-- | Handle the common case of fetching Profile information a JSON endpoint
|
-- | Handle the common case of fetching Profile information a JSON endpoint
|
||||||
|
|||||||
@ -88,7 +88,10 @@ oauth2EveScoped :: YesodAuth m
|
|||||||
-> [Text] -- ^ List of scopes to request
|
-> [Text] -- ^ List of scopes to request
|
||||||
-> Maybe (WidgetT m IO ()) -- ^ Login-Widget
|
-> Maybe (WidgetT m IO ()) -- ^ Login-Widget
|
||||||
-> AuthPlugin m
|
-> 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
|
where
|
||||||
oauth = OAuth2
|
oauth = OAuth2
|
||||||
{ oauthClientId = encodeUtf8 clientId
|
{ oauthClientId = encodeUtf8 clientId
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user