Combined authFacebook and authFacebookPerms

This commit is contained in:
Michael Snoyman 2010-06-30 21:45:42 +03:00
parent 058b738b4a
commit ea48760294

View File

@ -49,7 +49,6 @@ import Control.Applicative
import Control.Concurrent.MVar import Control.Concurrent.MVar
import System.IO import System.IO
import Control.Monad.Attempt import Control.Monad.Attempt
import Data.Monoid (mempty)
import Data.ByteString.Lazy.UTF8 (fromString) import Data.ByteString.Lazy.UTF8 (fromString)
import Data.Object import Data.Object
@ -83,8 +82,8 @@ data Auth = Auth
{ authIsOpenIdEnabled :: Bool { authIsOpenIdEnabled :: Bool
, authRpxnowApiKey :: Maybe String , authRpxnowApiKey :: Maybe String
, authEmailSettings :: Maybe AuthEmailSettings , authEmailSettings :: Maybe AuthEmailSettings
, authFacebook :: Maybe (String, String) -- ^ client id and secret -- | client id, secret and requested permissions
, authFacebookPerms :: [String] , authFacebook :: Maybe (String, String, [String])
} }
-- | Which subsystem authenticated the user. -- | Which subsystem authenticated the user.
@ -492,7 +491,7 @@ getFacebookR = do
a <- authFacebook <$> getYesodSub a <- authFacebook <$> getYesodSub
case a of case a of
Nothing -> notFound Nothing -> notFound
Just (cid, secret) -> do Just (cid, secret, _) -> do
render <- getUrlRender render <- getUrlRender
tm <- getRouteToMaster tm <- getRouteToMaster
let fb = Facebook.Facebook cid secret $ render $ tm FacebookR let fb = Facebook.Facebook cid secret $ render $ tm FacebookR
@ -514,9 +513,9 @@ getStartFacebookR = do
y <- getYesodSub y <- getYesodSub
case authFacebook y of case authFacebook y of
Nothing -> notFound Nothing -> notFound
Just (cid, secret) -> do Just (cid, secret, perms) -> do
render <- getUrlRender render <- getUrlRender
tm <- getRouteToMaster tm <- getRouteToMaster
let fb = Facebook.Facebook cid secret $ render $ tm FacebookR let fb = Facebook.Facebook cid secret $ render $ tm FacebookR
let fburl = Facebook.getForwardUrl fb $ authFacebookPerms y let fburl = Facebook.getForwardUrl fb perms
redirectString RedirectTemporary fburl redirectString RedirectTemporary fburl