+2
-2
@@ -83,7 +83,7 @@ app reqBody req =
|
||||
)
|
||||
] (cs $ fromMaybe "[]" body)
|
||||
|
||||
(["dbapi", "users"], "POST") -> do
|
||||
(["postgrest", "users"], "POST") -> do
|
||||
let user = decode reqBody :: Maybe AuthUser
|
||||
|
||||
case user of
|
||||
@@ -94,7 +94,7 @@ app reqBody req =
|
||||
(cs $ userPass u) (cs $ userRole u)
|
||||
return $ responseLBS status201
|
||||
[ jsonH
|
||||
, (hLocation, "/dbapi/users?id=eq." <> cs (userId u))
|
||||
, (hLocation, "/postgrest/users?id=eq." <> cs (userId u))
|
||||
] ""
|
||||
|
||||
([table], "POST") ->
|
||||
|
||||
+2
-2
@@ -55,12 +55,12 @@ addUser :: Text -> Text -> Text -> H.Tx H.Postgres s ()
|
||||
addUser identity pass role = do
|
||||
let Just hashed = unsafePerformIO $ hashPasswordUsingPolicy fastBcryptHashingPolicy (cs pass)
|
||||
H.unit $
|
||||
[H.q|insert into dbapi.auth (id, pass, rolname) values (?, ?, ?)|]
|
||||
[H.q|insert into postgrest.auth (id, pass, rolname) values (?, ?, ?)|]
|
||||
identity (cs hashed :: Text) role
|
||||
|
||||
signInRole :: Text -> Text -> H.Tx H.Postgres s LoginAttempt
|
||||
signInRole user pass = do
|
||||
u <- H.single $ [H.q|select pass, rolname from dbapi.auth where id = ?|] user
|
||||
u <- H.single $ [H.q|select pass, rolname from postgrest.auth where id = ?|] user
|
||||
return $ maybe LoginFailed (\r ->
|
||||
let (hashed, role) = r in
|
||||
if checkPass hashed pass
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ main = do
|
||||
H.sessionSettings (fromIntegral $ configPool conf) 30
|
||||
|
||||
let appSettings = setPort port
|
||||
. setServerName (cs $ "dbapi/" <> prettyVersion)
|
||||
. setServerName (cs $ "postgrest/" <> prettyVersion)
|
||||
$ defaultSettings
|
||||
middle =
|
||||
(if configSecure conf then redirectInsecure else id)
|
||||
|
||||
Reference in New Issue
Block a user