From ad034dbaccec8b3c69ca4c54c0953f79dea114fc Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 4 Mar 2019 08:14:36 +0000 Subject: [PATCH] Make the registration switch work again --- src/Vervis/Foundation.hs | 17 ++++++++++++++++- stack.yaml | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 04f58d2..d393883 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -544,9 +544,24 @@ instance YesodAuthAccount AccountPersistDB' App where passphraseResetKeyDuration _ = Just $ fromTimeUnit (1 :: Day) allowLoginByEmailAddress _ = True runAccountDB = unAccountPersistDB' - unregisteredLogin u = do + + unregisteredLogin u = do setUnverifiedCreds True $ Creds "account" (username u) [] return mempty + registrationAllowed = do + settings <- getsYesod appSettings + if appRegister settings + then do + room <- case appAccounts settings of + Nothing -> return True + Just cap -> do + current <- runDB $ count ([] :: [Filter Person]) + return $ current < cap + return $ + if room + then Nothing + else Just $ setMessage "Maximal number of registered users reached" + else return $ Just $ setMessage "User registration disabled" -- This instance is required to use forms. You can modify renderMessage to -- achieve customized and internationalized form validation messages. diff --git a/stack.yaml b/stack.yaml index 8e7b249..b70d08f 100644 --- a/stack.yaml +++ b/stack.yaml @@ -27,7 +27,7 @@ packages: # - lib/yesod-auth-account - location: git: https://dev.angeley.es/s/fr33domlover/r/yesod-auth-account - commit: c14795264c3d63b2126e91e98107a631405cea74 + commit: 4dcd84c4007212540c76113ca2fd5bf0dd9ead5f extra-dep: true - lib/yesod-http-signature - lib/yesod-mail-send