mirror of https://github.com/zulip/zulip.git
confirmation: Add validity_in_days to _properties.
Also renames settings.EMAIL_CONFIRMATION_DAYS to CONFIRMATION_LINK_DEFAULT_VALIDITY_DAYS, and adds a new setting for invitation links.
This commit is contained in:
parent
d689d37a75
commit
a249822ff5
|
@ -31,7 +31,7 @@ def get_object_from_key(confirmation_key):
|
|||
return False
|
||||
|
||||
time_elapsed = timezone_now() - confirmation.date_sent
|
||||
if time_elapsed.total_seconds() > settings.EMAIL_CONFIRMATION_DAYS * 24 * 3600:
|
||||
if time_elapsed.total_seconds() > _properties[confirmation.type].validity_in_days * 24 * 3600:
|
||||
return False
|
||||
|
||||
obj = confirmation.content_object
|
||||
|
@ -73,13 +73,15 @@ class Confirmation(models.Model):
|
|||
return '<Confirmation: %s>' % (self.content_object,)
|
||||
|
||||
class ConfirmationType(object):
|
||||
def __init__(self, url_name):
|
||||
# type: (str) -> None
|
||||
def __init__(self, url_name, validity_in_days=settings.CONFIRMATION_LINK_DEFAULT_VALIDITY_DAYS):
|
||||
# type: (str, int) -> None
|
||||
self.url_name = url_name
|
||||
self.validity_in_days = validity_in_days
|
||||
|
||||
_properties = {
|
||||
Confirmation.USER_REGISTRATION: ConfirmationType('confirmation.views.confirm'),
|
||||
Confirmation.INVITATION: ConfirmationType('confirmation.views.confirm'),
|
||||
Confirmation.INVITATION: ConfirmationType('confirmation.views.confirm',
|
||||
validity_in_days=settings.INVITATION_LINK_VALIDITY_DAYS),
|
||||
Confirmation.EMAIL_CHANGE: ConfirmationType('zerver.views.user_settings.confirm_email_change'),
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,6 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '',
|
|||
'TWITTER_CONSUMER_SECRET': '',
|
||||
'TWITTER_ACCESS_TOKEN_KEY': '',
|
||||
'TWITTER_ACCESS_TOKEN_SECRET': '',
|
||||
'EMAIL_CONFIRMATION_DAYS': 1,
|
||||
'EMAIL_GATEWAY_PATTERN': '',
|
||||
'EMAIL_GATEWAY_EXAMPLE': '',
|
||||
'EMAIL_GATEWAY_BOT': None,
|
||||
|
@ -201,6 +200,8 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '',
|
|||
"general": {"description": "For general stuff", "invite_only": False},
|
||||
"zulip": {"description": "For zulip stuff", "invite_only": False}
|
||||
},
|
||||
'CONFIRMATION_LINK_DEFAULT_VALIDITY_DAYS': 1,
|
||||
'INVITATION_LINK_VALIDITY_DAYS': 10,
|
||||
'REALM_CREATION_LINK_VALIDITY_DAYS': 7,
|
||||
'TERMS_OF_SERVICE': None,
|
||||
'PRIVACY_POLICY': None,
|
||||
|
|
Loading…
Reference in New Issue