implement signup block
This commit is contained in:
parent
92a71e518f
commit
ddb26faf5c
2 changed files with 27 additions and 17 deletions
|
@ -34,8 +34,15 @@ userNew
|
||||||
:: UserSubmit
|
:: UserSubmit
|
||||||
-> MateHandler Int
|
-> MateHandler Int
|
||||||
userNew (UserSubmit ident email pass) = do
|
userNew (UserSubmit ident email pass) = do
|
||||||
now <- liftIO getCurrentTime
|
|
||||||
conn <- asks rsConnection
|
conn <- asks rsConnection
|
||||||
|
block <- selectSignupBlocked conn
|
||||||
|
if block
|
||||||
|
then
|
||||||
|
throwError $ err401
|
||||||
|
{ errBody = "User registration has been disabled"
|
||||||
|
}
|
||||||
|
else do
|
||||||
|
now <- liftIO getCurrentTime
|
||||||
uid <- insertUser ident email (utctDay now) conn
|
uid <- insertUser ident email (utctDay now) conn
|
||||||
salt <- liftIO randomString
|
salt <- liftIO randomString
|
||||||
let mpasshash = argon2 salt (encodeUtf8 pass)
|
let mpasshash = argon2 salt (encodeUtf8 pass)
|
||||||
|
|
|
@ -59,6 +59,9 @@ selectSettings conn = liftIO $ do
|
||||||
selectIdleTime :: PGS.Connection -> MateHandler Int
|
selectIdleTime :: PGS.Connection -> MateHandler Int
|
||||||
selectIdleTime conn = settingsIdleTime <$> selectSettings conn
|
selectIdleTime conn = settingsIdleTime <$> selectSettings conn
|
||||||
|
|
||||||
|
selectSignupBlocked :: PGS.Connection -> MateHandler Bool
|
||||||
|
selectSignupBlocked conn = settingsBlockRegistration <$> selectSettings conn
|
||||||
|
|
||||||
updateSettings :: Settings -> PGS.Connection -> MateHandler ()
|
updateSettings :: Settings -> PGS.Connection -> MateHandler ()
|
||||||
updateSettings (Settings block imprint idleTime) conn = do
|
updateSettings (Settings block imprint idleTime) conn = do
|
||||||
void $ liftIO $ runUpdate_ conn $ Update
|
void $ liftIO $ runUpdate_ conn $ Update
|
||||||
|
|
Loading…
Reference in a new issue