feat: configurable invite expiry time (#1573)

This commit is contained in:
Matri 2023-11-21 11:50:06 +08:00 committed by GitHub
parent 7cda3fe85b
commit d0456d0f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -60,7 +60,8 @@ DEFAULTS = {
'UPLOAD_FILE_BATCH_LIMIT': 5,
'UPLOAD_IMAGE_FILE_SIZE_LIMIT': 10,
'OUTPUT_MODERATION_BUFFER_SIZE': 300,
'MULTIMODAL_SEND_IMAGE_FORMAT': 'base64'
'MULTIMODAL_SEND_IMAGE_FORMAT': 'base64',
'INVITE_EXPIRY_HOURS': 72
}
@ -218,6 +219,11 @@ class Config:
self.MAIL_TYPE = get_env('MAIL_TYPE')
self.MAIL_DEFAULT_SEND_FROM = get_env('MAIL_DEFAULT_SEND_FROM')
self.RESEND_API_KEY = get_env('RESEND_API_KEY')
# ------------------------
# Workpace Configurations.
# ------------------------
self.INVITE_EXPIRY_HOURS = int(get_env('INVITE_EXPIRY_HOURS'))
# ------------------------
# Sentry Configurations.

View File

@ -489,9 +489,10 @@ class RegisterService:
'email': account.email,
'workspace_id': tenant.id,
}
expiryHours = current_app.config['INVITE_EXPIRY_HOURS']
redis_client.setex(
cls._get_invitation_token_key(token),
3600,
expiryHours * 60 * 60,
json.dumps(invitation_data)
)
return token