Merge pull request #350 from mikesteele81/googleauth
yesod-auth: change returned Creds identifier to "googleemail".
This commit is contained in:
commit
3a21986165
@ -31,17 +31,20 @@ import qualified Yesod.Auth.Message as Msg
|
|||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Control.Exception.Lifted (try, SomeException)
|
import Control.Exception.Lifted (try, SomeException)
|
||||||
|
|
||||||
|
pid :: Text
|
||||||
|
pid = "googleemail"
|
||||||
|
|
||||||
forwardUrl :: AuthRoute
|
forwardUrl :: AuthRoute
|
||||||
forwardUrl = PluginR "googleemail" ["forward"]
|
forwardUrl = PluginR pid ["forward"]
|
||||||
|
|
||||||
googleIdent :: Text
|
googleIdent :: Text
|
||||||
googleIdent = "https://www.google.com/accounts/o8/id"
|
googleIdent = "https://www.google.com/accounts/o8/id"
|
||||||
|
|
||||||
authGoogleEmail :: YesodAuth m => AuthPlugin m
|
authGoogleEmail :: YesodAuth m => AuthPlugin m
|
||||||
authGoogleEmail =
|
authGoogleEmail =
|
||||||
AuthPlugin "googleemail" dispatch login
|
AuthPlugin pid dispatch login
|
||||||
where
|
where
|
||||||
complete = PluginR "googleemail" ["complete"]
|
complete = PluginR pid ["complete"]
|
||||||
login tm =
|
login tm =
|
||||||
[whamlet|<a href=@{tm forwardUrl}>_{Msg.LoginGoogle}|]
|
[whamlet|<a href=@{tm forwardUrl}>_{Msg.LoginGoogle}|]
|
||||||
dispatch "GET" ["forward"] = do
|
dispatch "GET" ["forward"] = do
|
||||||
@ -86,7 +89,7 @@ completeHelper gets' = do
|
|||||||
let OpenId.Identifier ident = OpenId.oirOpLocal oir
|
let OpenId.Identifier ident = OpenId.oirOpLocal oir
|
||||||
memail <- lookupGetParam "openid.ext1.value.email"
|
memail <- lookupGetParam "openid.ext1.value.email"
|
||||||
case (memail, "https://www.google.com/accounts/o8/id" `T.isPrefixOf` ident) of
|
case (memail, "https://www.google.com/accounts/o8/id" `T.isPrefixOf` ident) of
|
||||||
(Just email, True) -> setCreds True $ Creds "openid" email []
|
(Just email, True) -> setCreds True $ Creds pid email []
|
||||||
(_, False) -> do
|
(_, False) -> do
|
||||||
setMessage "Only Google login is supported"
|
setMessage "Only Google login is supported"
|
||||||
redirect $ toMaster LoginR
|
redirect $ toMaster LoginR
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user