July 7 - Fix reset link hasn't been sent 2
This commit is contained in:
+8
-4
@@ -1,5 +1,4 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request, abort
|
||||
from urllib.parse import urlparse
|
||||
from flask_login import login_user, logout_user, login_required, current_user
|
||||
from app import db, limiter
|
||||
from app.models.user import User
|
||||
@@ -403,7 +402,6 @@ def _send_password_reset_email(user, token, base_url=None):
|
||||
from flask import current_app, render_template_string, url_for as _url_for
|
||||
from flask_mail import Message
|
||||
from app import mail
|
||||
from urllib.parse import urlparse
|
||||
import threading
|
||||
|
||||
if not current_app.config.get('MAIL_SERVER'):
|
||||
@@ -412,8 +410,14 @@ def _send_password_reset_email(user, token, base_url=None):
|
||||
|
||||
effective_base = (base_url or current_app.config.get('APP_BASE_URL', '')).rstrip('/')
|
||||
reset_link = f'{effective_base}{_url_for("auth.reset_password", token=token)}'
|
||||
host = urlparse(effective_base).netloc or 'janitorialqc.local'
|
||||
sender = f'noreply@{host}'
|
||||
# From MUST be the authenticated SMTP identity, otherwise the mail server
|
||||
# accepts the message but it is dropped downstream by SPF/DMARC/relay policy
|
||||
# (a per-host noreply@<domain> is NOT an authorized sender). The per-domain
|
||||
# host is still reflected in the reset LINK above, preserving rule 64's
|
||||
# multi-domain intent without breaking deliverability.
|
||||
sender = (current_app.config.get('MAIL_DEFAULT_SENDER')
|
||||
or current_app.config.get('MAIL_USERNAME')
|
||||
or 'noreply@janitorialqc.local')
|
||||
|
||||
html_body = render_template_string("""<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -179,7 +179,6 @@ def _send_invite_email(user, token, base_url=None):
|
||||
from flask import current_app, render_template_string
|
||||
from flask_mail import Message
|
||||
from app import mail
|
||||
from urllib.parse import urlparse
|
||||
import threading
|
||||
|
||||
if not current_app.config.get('MAIL_SERVER'):
|
||||
@@ -189,8 +188,12 @@ def _send_invite_email(user, token, base_url=None):
|
||||
effective_base = (base_url or current_app.config.get('APP_BASE_URL', '')).rstrip('/')
|
||||
setup_link = f'{effective_base}{url_for("customers.set_password", token=token)}'
|
||||
|
||||
host = urlparse(effective_base).netloc or 'janitorialqc.local'
|
||||
sender = f'noreply@{host}'
|
||||
# From MUST be the authenticated SMTP identity (MAIL_DEFAULT_SENDER); a
|
||||
# per-host noreply@<domain> is accepted by the relay but dropped downstream
|
||||
# by SPF/DMARC. The per-domain host is still preserved in setup_link above.
|
||||
sender = (current_app.config.get('MAIL_DEFAULT_SENDER')
|
||||
or current_app.config.get('MAIL_USERNAME')
|
||||
or 'noreply@janitorialqc.local')
|
||||
|
||||
html_body = render_template_string("""<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
Reference in New Issue
Block a user