password reset
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -30,9 +30,11 @@ def create_default_templates():
|
||||
'body': '''
|
||||
<h2>Password Reset Request</h2>
|
||||
<p>Dear {{ user.username }},</p>
|
||||
<p>We received a request to reset your password. Click the link below to set a new password:</p>
|
||||
<p><a href="{{ reset_link }}">Reset Password</a></p>
|
||||
<p>If you didn't request this, please ignore this email or contact support if you have concerns.</p>
|
||||
<p>We received a request to reset your password for your DocuPulse account. Click the link below to set a new password:</p>
|
||||
<p><a href="{{ reset_link }}" style="background-color: #16767b; color: white; padding: 12px 24px; text-decoration: none; border-radius: 5px; display: inline-block; margin: 10px 0;">Reset Password</a></p>
|
||||
<p><strong>This link will expire in 1 hour.</strong></p>
|
||||
<p>If you didn't request this password reset, please ignore this email. Your password will remain unchanged.</p>
|
||||
<p>If you have any concerns about your account security, please contact your administrator immediately.</p>
|
||||
<p>Best regards,<br>The DocuPulse Team</p>
|
||||
'''
|
||||
},
|
||||
|
||||
@@ -119,22 +119,44 @@ def generate_mail_from_notification(notif: Notif) -> Optional[Mail]:
|
||||
filled_body = filled_body.replace('{{ site.company_name }}', site_settings.company_name or '')
|
||||
filled_body = filled_body.replace('{{ site.company_website }}', site_settings.company_website or '')
|
||||
|
||||
# Add notification details
|
||||
# Add notification-specific variables
|
||||
if notif.details:
|
||||
for key, value in notif.details.items():
|
||||
# Handle nested keys (e.g., room.name -> room_name)
|
||||
if '.' in key:
|
||||
parts = key.split('.')
|
||||
if len(parts) == 2:
|
||||
obj_name, attr = parts
|
||||
if obj_name in notif.details and isinstance(notif.details[obj_name], dict):
|
||||
if attr in notif.details[obj_name]:
|
||||
filled_body = filled_body.replace(f'{{{{ {key} }}}}', str(notif.details[obj_name][attr]))
|
||||
else:
|
||||
# Special handling for setup_link to ensure it's a proper URL
|
||||
if key == 'setup_link' and value.startswith('http://http//'):
|
||||
value = value.replace('http://http//', 'http://')
|
||||
filled_body = filled_body.replace(f'{{{{ {key} }}}}', str(value))
|
||||
if 'setup_link' in filled_body and 'setup_link' in notif.details:
|
||||
filled_body = filled_body.replace('{{ setup_link }}', notif.details['setup_link'])
|
||||
if 'reset_link' in filled_body and 'reset_link' in notif.details:
|
||||
filled_body = filled_body.replace('{{ reset_link }}', notif.details['reset_link'])
|
||||
if 'expiry_time' in filled_body and 'expiry_time' in notif.details:
|
||||
filled_body = filled_body.replace('{{ expiry_time }}', notif.details['expiry_time'])
|
||||
if 'created_by' in filled_body and 'created_by' in notif.details:
|
||||
filled_body = filled_body.replace('{{ created_by }}', notif.details['created_by'])
|
||||
if 'deleted_by' in filled_body and 'deleted_by' in notif.details:
|
||||
filled_body = filled_body.replace('{{ deleted_by }}', notif.details['deleted_by'])
|
||||
if 'updated_by' in filled_body and 'updated_by' in notif.details:
|
||||
filled_body = filled_body.replace('{{ updated_by }}', notif.details['updated_by'])
|
||||
if 'remover.username' in filled_body and 'remover' in notif.details:
|
||||
filled_body = filled_body.replace('{{ remover.username }}', notif.details['remover'])
|
||||
if 'sender.username' in filled_body and 'sender' in notif.details:
|
||||
filled_body = filled_body.replace('{{ sender.username }}', notif.details['sender'])
|
||||
if 'conversation.name' in filled_body and 'conversation' in notif.details:
|
||||
filled_body = filled_body.replace('{{ conversation.name }}', notif.details['conversation'])
|
||||
if 'conversation.description' in filled_body and 'conversation_description' in notif.details:
|
||||
filled_body = filled_body.replace('{{ conversation.description }}', notif.details['conversation_description'])
|
||||
if 'message.content' in filled_body and 'message' in notif.details:
|
||||
filled_body = filled_body.replace('{{ message.content }}', notif.details['message'])
|
||||
if 'message.created_at' in filled_body and 'message_created_at' in notif.details:
|
||||
filled_body = filled_body.replace('{{ message.created_at }}', notif.details['message_created_at'])
|
||||
if 'message_link' in filled_body and 'message_link' in notif.details:
|
||||
filled_body = filled_body.replace('{{ message_link }}', notif.details['message_link'])
|
||||
if 'updated_fields' in filled_body and 'updated_fields' in notif.details:
|
||||
filled_body = filled_body.replace('{{ updated_fields }}', notif.details['updated_fields'])
|
||||
if 'created_at' in filled_body:
|
||||
filled_body = filled_body.replace('{{ created_at }}', datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
if 'updated_at' in filled_body:
|
||||
filled_body = filled_body.replace('{{ updated_at }}', datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
if 'deleted_at' in filled_body:
|
||||
filled_body = filled_body.replace('{{ deleted_at }}', datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
if 'removed_at' in filled_body:
|
||||
filled_body = filled_body.replace('{{ removed_at }}', datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
|
||||
# Handle special URL variables
|
||||
if 'room_link' in filled_body and 'room_id' in notif.details:
|
||||
@@ -147,15 +169,6 @@ def generate_mail_from_notification(notif: Notif) -> Optional[Mail]:
|
||||
conversation_link = url_for('conversations.conversation', conversation_id=notif.details['conversation_id'], _external=True)
|
||||
filled_body = filled_body.replace('{{ conversation_link }}', conversation_link)
|
||||
|
||||
# Add timestamps
|
||||
filled_body = filled_body.replace('{{ created_at }}', notif.timestamp.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
if 'updated_at' in filled_body:
|
||||
filled_body = filled_body.replace('{{ updated_at }}', datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
if 'deleted_at' in filled_body:
|
||||
filled_body = filled_body.replace('{{ deleted_at }}', datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
if 'removed_at' in filled_body:
|
||||
filled_body = filled_body.replace('{{ removed_at }}', datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
|
||||
# Create a new Mail record
|
||||
mail = Mail(
|
||||
recipient=notif.user.email,
|
||||
|
||||
Reference in New Issue
Block a user