make registration block configurable from UI
This commit is contained in:
parent
80d80e2a5d
commit
fb679ff96b
2 changed files with 8 additions and 15 deletions
|
@ -18,7 +18,7 @@ data ServerConfig = ServerConfig
|
|||
, configListenPort :: Word
|
||||
, configListenHost :: T.Text
|
||||
-- , configMaxConnectionsPerClient :: Word
|
||||
, configBlockRegistration :: Bool
|
||||
-- , configBlockRegistration :: Bool
|
||||
, configSendmailPath :: FilePath
|
||||
}
|
||||
deriving (Show)
|
||||
|
@ -35,8 +35,9 @@ instance FromJSON ServerConfig where
|
|||
<*> m .: "listen_port"
|
||||
<*> m .:? "listen_host" .!= "127.0.0.1"
|
||||
-- <*> m .:? "max_connections_per_client" .!= 10
|
||||
<*> m .: "block_registration"
|
||||
-- <*> m .: "block_registration"
|
||||
<*> m .: "sendmail_path"
|
||||
parseJSON _ = error "Can not parse configuration"
|
||||
|
||||
data Options = Options
|
||||
{ optConfigLocation :: T.Text
|
||||
|
|
18
app/Main.hs
18
app/Main.hs
|
@ -73,7 +73,7 @@ main = do
|
|||
lport
|
||||
lhost
|
||||
-- max_conn_per_client
|
||||
block_registration
|
||||
-- block_registration
|
||||
sendmail_path
|
||||
) -> do
|
||||
conn <- connectPostgreSQL (
|
||||
|
@ -142,7 +142,7 @@ main = do
|
|||
in Right $ Address $ toSockAddr (read (B8.unpack xaddr), defaultPort)
|
||||
Nothing -> Right $ Address $ remoteHost req
|
||||
)
|
||||
runSettings settings (throttle th (app block_registration initState))
|
||||
runSettings settings (throttle th (app initState))
|
||||
where
|
||||
opts = info (options <**> helper)
|
||||
( fullDesc
|
||||
|
@ -150,9 +150,9 @@ main = do
|
|||
<> header "mateamt - Your friendly mate distribution office"
|
||||
)
|
||||
|
||||
app :: Bool -> ReadState -> Application
|
||||
app :: ReadState -> Application
|
||||
-- app conn = serveWithContext userApi genAuthServerContext (users conn)
|
||||
app block_registration initState =
|
||||
app initState =
|
||||
serveWithContext mateApi (genAuthServerContext (rsConnection initState)) $
|
||||
hoistServerWithContext
|
||||
mateApi
|
||||
|
@ -166,15 +166,7 @@ app block_registration initState =
|
|||
authManageNewAuth :<|>
|
||||
authManageDeleteAuth :<|>
|
||||
|
||||
(
|
||||
if block_registration
|
||||
then
|
||||
const $ throwError $ err406
|
||||
{ errBody = "User registration is not allowed."
|
||||
}
|
||||
else
|
||||
userNew
|
||||
) :<|>
|
||||
userNew :<|>
|
||||
userGet :<|>
|
||||
userUpdate :<|>
|
||||
userList :<|>
|
||||
|
|
Loading…
Reference in a new issue