From 78b5bad2c4c0d13db30c9cfd10b08dfcde0d2f99 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 4 Mar 2019 14:51:51 +0000 Subject: [PATCH] Support bypassing email verification of new users --- config/settings-default.yaml | 5 +++++ src/Vervis/Foundation.hs | 1 + src/Vervis/Settings.hs | 4 ++++ stack.yaml | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/settings-default.yaml b/config/settings-default.yaml index eeb8037..292f5aa 100644 --- a/config/settings-default.yaml +++ b/config/settings-default.yaml @@ -102,6 +102,11 @@ ssh-key-file: config/ssh-host-key registration: false max-accounts: 3 +# Whether to verify users' email addresses by sending them email with a +# verification link. If not set below, the default is not to verify in +# development, and to verify otherwise. +#email-verification: true + ############################################################################### # Mail ############################################################################### diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index fcdcbfe..696d049 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -541,6 +541,7 @@ instance YesodAuthVerify App where verificationRoute _ = ResendVerifyEmailR instance YesodAuthAccount AccountPersistDB' App where + requireEmailVerification = appEmailVerification . appSettings emailVerifyKeyDuration _ = Just $ fromTimeUnit (1 :: Day) passphraseResetKeyDuration _ = Just $ fromTimeUnit (1 :: Day) allowLoginByEmailAddress _ = True diff --git a/src/Vervis/Settings.hs b/src/Vervis/Settings.hs index cccbf45..e28ed07 100644 --- a/src/Vervis/Settings.hs +++ b/src/Vervis/Settings.hs @@ -108,6 +108,9 @@ data AppSettings = AppSettings , appRegister :: Bool -- | The maximal number of user accounts that can be registered. , appAccounts :: Maybe Int + -- | Whether to send verification email to new users. If not, users will + -- be instantly considered verified, without sending email. + , appEmailVerification :: Bool -- | SMTP server details for sending email, and other email related -- details. If set to 'Nothing', no email will be sent. , appMail :: Maybe MailSettings @@ -171,6 +174,7 @@ instance FromJSON AppSettings where appSshKeyFile <- o .: "ssh-key-file" appRegister <- o .: "registration" appAccounts <- o .: "max-accounts" + appEmailVerification <- o .:? "email-verification" .!= not defaultDev appMail <- o .:? "mail" appCapabilitySigningKeyFile <- o .: "capability-signing-key" diff --git a/stack.yaml b/stack.yaml index b70d08f..fbd3349 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: 4dcd84c4007212540c76113ca2fd5bf0dd9ead5f + commit: 2d19eea0fae58897a02372a84cc48e7696a4e288 extra-dep: true - lib/yesod-http-signature - lib/yesod-mail-send