Add /dbapi/users route for creating new user

This commit is contained in:
Joe Nelson
2014-10-21 15:01:04 -07:00
parent 5953936c7a
commit 572c235b79
5 changed files with 50 additions and 13 deletions
+4 -4
View File
@@ -170,10 +170,10 @@ insert schema table row conn = do
addUser :: BS.ByteString -> BS.ByteString -> BS.ByteString -> Connection -> IO ()
addUser identity pass role conn = do
hashed <- hashPasswordUsingPolicy fastBcryptHashingPolicy $ cs pass
_ <- insert "dbapi" "auth" (SqlRow [
("id", toSql identity), ("pass", toSql hashed), ("rolname", toSql role)
]) conn
Just hashed <- hashPasswordUsingPolicy fastBcryptHashingPolicy $ cs pass
_ <- quickQuery conn
"insert into dbapi.auth (id, pass, rolname) values (?, ?, ?)"
$ map toSql [identity, hashed, role]
return ()
signInRole :: BS.ByteString -> BS.ByteString -> Connection -> IO LoginAttempt