Temporarily remove sessionIpAddress (#243)

This commit is contained in:
Michael Snoyman 2012-01-31 06:53:47 +02:00
parent 4962529006
commit 2f38ddaff3
8 changed files with 22 additions and 15 deletions

View File

@ -137,6 +137,7 @@ setPassword pwd u = do salt <- randomSalt
-- the database values.
validateUser :: ( YesodPersist yesod
, b ~ YesodPersistBackend yesod
, b ~ PersistEntityBackend user
, PersistStore b (GHandler sub yesod)
, PersistUnique b (GHandler sub yesod)
, PersistEntity user
@ -163,6 +164,7 @@ login = PluginR "hashdb" ["login"]
-- username (whatever it might be) to unique user ID.
postLoginR :: ( YesodAuth y, YesodPersist y
, b ~ YesodPersistBackend y
, b ~ PersistEntityBackend user
, HashDBUser user, PersistEntity user
, PersistStore b (GHandler Auth y)
, PersistUnique b (GHandler Auth y))
@ -188,6 +190,7 @@ getAuthIdHashDB :: ( YesodAuth master, YesodPersist master
, HashDBUser user, PersistEntity user
, Key b user ~ AuthId master
, b ~ YesodPersistBackend master
, b ~ PersistEntityBackend user
, PersistUnique b (GHandler sub master)
, PersistStore b (GHandler sub master))
=> (AuthRoute -> Route master) -- ^ your site's Auth Route
@ -216,6 +219,7 @@ authHashDB :: ( YesodAuth m, YesodPersist m
, HashDBUser user
, PersistEntity user
, b ~ YesodPersistBackend m
, b ~ PersistEntityBackend user
, PersistStore b (GHandler Auth m)
, PersistUnique b (GHandler Auth m))
=> (Text -> Maybe (Unique user b)) -> AuthPlugin m

View File

@ -39,8 +39,8 @@ library
, unordered-containers
, yesod-form >= 0.4 && < 0.5
, transformers >= 0.2.2 && < 0.3
, persistent >= 0.7 && < 0.8
, persistent-template >= 0.7 && < 0.8
, persistent >= 0.8 && < 0.9
, persistent-template >= 0.8 && < 0.9
, SHA >= 1.4.1.3 && < 1.6
, http-conduit >= 1.2 && < 1.3
, aeson >= 0.5

View File

@ -253,6 +253,7 @@ class RenderRoute a => Yesod a where
-> GHandler sub a (Maybe (Either Text (Route a, [(Text, Text)])))
addStaticContent _ _ _ = return Nothing
{- Temporarily disabled until we have a better interface.
-- | Whether or not to tie a session to a specific IP address. Defaults to
-- 'False'.
--
@ -261,6 +262,7 @@ class RenderRoute a => Yesod a where
-- function correctly if the user is behind a proxy.
sessionIpAddress :: a -> Bool
sessionIpAddress _ = False
-}
-- | The path value to set for cookies. By default, uses \"\/\", meaning
-- cookies will be sent to every page on the current domain.
@ -364,8 +366,8 @@ defaultYesodRunner handler master sub murl toMasterRoute mkey req = do
now <- {-# SCC "getCurrentTime" #-} liftIO getCurrentTime
let getExpires m = {-# SCC "getExpires" #-} fromIntegral (m * 60) `addUTCTime` now
let exp' = {-# SCC "exp'" #-} getExpires $ clientSessionDuration master
let rh = {-# SCC "rh" #-} takeWhile (/= ':') $ show $ W.remoteHost req
let host = if sessionIpAddress master then S8.pack rh else ""
--let rh = {-# SCC "rh" #-} takeWhile (/= ':') $ show $ W.remoteHost req
let host = "" -- FIXME if sessionIpAddress master then S8.pack rh else ""
let session' = {-# SCC "session'" #-}
case mkey of
Nothing -> []

View File

@ -1,4 +1,5 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE CPP #-}
@ -64,6 +65,7 @@ import Data.Maybe (listToMaybe)
import qualified Blaze.ByteString.Builder.Html.Utf8 as B
import Blaze.ByteString.Builder (writeByteString, toLazyByteString)
import Blaze.ByteString.Builder.Internal.Write (fromWriteList)
import Database.Persist.Store (PersistEntityBackend)
import Text.Blaze.Renderer.String (renderHtml)
import qualified Data.ByteString as S
@ -442,8 +444,9 @@ optionsPersist :: ( YesodPersist master, PersistEntity a
, PersistQuery (YesodPersistBackend master) (GHandler sub master)
, PathPiece (Key (YesodPersistBackend master) a)
, RenderMessage master msg
, PersistEntityBackend a ~ YesodPersistBackend master
)
=> [Filter a] -> [SelectOpt a] -> (a -> msg) -> GHandler sub master (OptionList (Entity (YesodPersistBackend master) a))
=> [Filter a] -> [SelectOpt a] -> (a -> msg) -> GHandler sub master (OptionList (Entity a))
optionsPersist filts ords toDisplay = fmap mkOptionList $ do
mr <- getMessageRender
pairs <- runDB $ selectList filts ords

View File

@ -20,7 +20,7 @@ library
, hamlet >= 0.10 && < 0.11
, shakespeare-css >= 0.10 && < 0.11
, shakespeare-js >= 0.10 && < 0.11
, persistent >= 0.7 && < 0.8
, persistent >= 0.8 && < 0.9
, template-haskell
, transformers >= 0.2.2 && < 0.3
, data-default >= 0.3 && < 0.4

View File

@ -42,8 +42,9 @@ getBy404 :: ( PersistUnique b m
, m ~ GHandler sub master
, Monad (b m)
, MonadTrans b
, PersistEntityBackend val ~ b
)
=> Unique val b -> b m (Entity b val)
=> Unique val b -> b m (Entity val)
getBy404 key = do
mres <- getBy key
case mres of

View File

@ -15,8 +15,8 @@ description: Some helpers for using Persistent from Yesod.
library
build-depends: base >= 4 && < 5
, yesod-core >= 0.10 && < 0.11
, persistent >= 0.7 && < 0.8
, persistent-template >= 0.7 && < 0.8
, persistent >= 0.8 && < 0.9
, persistent-template >= 0.8 && < 0.9
, transformers >= 0.2.2 && < 0.3
exposed-modules: Yesod.Persist
ghc-options: -Wall

View File

@ -115,13 +115,10 @@ scaffold = do
packages =
if backend == MongoDB
then " , persistent-mongoDB >= 0.6.1 && < 0.7\n , mongoDB >= 1.1\n , bson >= 0.1.5\n"
else " , persistent-" ++ backendLower ++ " >= 0.6 && < 0.7"
then " , persistent-mongoDB >= 0.8 && < 0.9\n , mongoDB >= 1.1\n , bson >= 0.1.5\n"
else " , persistent-" ++ backendLower ++ " >= 0.8 && < 0.9"
monadControlVersion =
if backend == MongoDB
then "== 0.2.*"
else "== 0.3.*"
monadControlVersion = "== 0.3.*"
let fst3 (x, _, _) = x