Support bypassing email verification of new users

This commit is contained in:
fr33domlover 2019-03-04 14:51:51 +00:00
parent c41f1183e0
commit 78b5bad2c4
4 changed files with 11 additions and 1 deletions

View file

@ -102,6 +102,11 @@ ssh-key-file: config/ssh-host-key
registration: false registration: false
max-accounts: 3 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 # Mail
############################################################################### ###############################################################################

View file

@ -541,6 +541,7 @@ instance YesodAuthVerify App where
verificationRoute _ = ResendVerifyEmailR verificationRoute _ = ResendVerifyEmailR
instance YesodAuthAccount AccountPersistDB' App where instance YesodAuthAccount AccountPersistDB' App where
requireEmailVerification = appEmailVerification . appSettings
emailVerifyKeyDuration _ = Just $ fromTimeUnit (1 :: Day) emailVerifyKeyDuration _ = Just $ fromTimeUnit (1 :: Day)
passphraseResetKeyDuration _ = Just $ fromTimeUnit (1 :: Day) passphraseResetKeyDuration _ = Just $ fromTimeUnit (1 :: Day)
allowLoginByEmailAddress _ = True allowLoginByEmailAddress _ = True

View file

@ -108,6 +108,9 @@ data AppSettings = AppSettings
, appRegister :: Bool , appRegister :: Bool
-- | The maximal number of user accounts that can be registered. -- | The maximal number of user accounts that can be registered.
, appAccounts :: Maybe Int , 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 -- | SMTP server details for sending email, and other email related
-- details. If set to 'Nothing', no email will be sent. -- details. If set to 'Nothing', no email will be sent.
, appMail :: Maybe MailSettings , appMail :: Maybe MailSettings
@ -171,6 +174,7 @@ instance FromJSON AppSettings where
appSshKeyFile <- o .: "ssh-key-file" appSshKeyFile <- o .: "ssh-key-file"
appRegister <- o .: "registration" appRegister <- o .: "registration"
appAccounts <- o .: "max-accounts" appAccounts <- o .: "max-accounts"
appEmailVerification <- o .:? "email-verification" .!= not defaultDev
appMail <- o .:? "mail" appMail <- o .:? "mail"
appCapabilitySigningKeyFile <- o .: "capability-signing-key" appCapabilitySigningKeyFile <- o .: "capability-signing-key"

View file

@ -27,7 +27,7 @@ packages:
# - lib/yesod-auth-account # - lib/yesod-auth-account
- location: - location:
git: https://dev.angeley.es/s/fr33domlover/r/yesod-auth-account git: https://dev.angeley.es/s/fr33domlover/r/yesod-auth-account
commit: 4dcd84c4007212540c76113ca2fd5bf0dd9ead5f commit: 2d19eea0fae58897a02372a84cc48e7696a4e288
extra-dep: true extra-dep: true
- lib/yesod-http-signature - lib/yesod-http-signature
- lib/yesod-mail-send - lib/yesod-mail-send