Optimization when auth role coincides with anon role

No need to set/reset role because it is already correct
This commit is contained in:
Joe Nelson
2014-12-29 09:39:13 -08:00
parent 24f70f5bdf
commit 2c635cfde8
4 changed files with 12 additions and 22 deletions
+3 -2
View File
@@ -44,14 +44,15 @@ pgSettings = H.ParamSettings "localhost" 5432 "postgrest_test" "" "postgrest_tes
withApp :: ActionWith Application -> IO ()
withApp perform =
let anonRole = cs $ configAnonRole cfg in
let anonRole = cs $ configAnonRole cfg
currRole = cs $ configDbUser cfg in
perform $ middle $ \req resp ->
H.session pgSettings testSettings $ H.sessionUnlifter >>= \unlift ->
liftIO $ do
body <- strictRequestBody req
resp =<< catchJust isSqlError
(unlift $ H.tx Nothing
$ authenticated anonRole (app body) req)
$ authenticated currRole anonRole (app body) req)
(return . sqlError)
where middle = cors corsPolicy