feat: notify admin when never-logged-in user activates account
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Sends email to admin when a user with last_login=NULL successfully sets their password via reset link (first-time activation). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
437bec63c1
commit
84169af76e
@ -1049,9 +1049,26 @@ def reset_password(token):
|
||||
user.verification_token_expires = None
|
||||
logger.info(f"Email auto-verified via password reset for {user.email}")
|
||||
|
||||
# Notify admin if this is a first-time activation (user never logged in)
|
||||
first_activation = user.last_login is None
|
||||
|
||||
db.commit()
|
||||
|
||||
logger.info(f"Password reset successful for {user.email}")
|
||||
|
||||
if first_activation:
|
||||
try:
|
||||
import email_service
|
||||
email_service.send_email(
|
||||
to=['maciej.pienczyn@inpi.pl'],
|
||||
subject=f'Aktywacja konta: {user.name}',
|
||||
body_text=f'{user.name} ({user.email}) właśnie ustawił(a) hasło i aktywował(a) swoje konto w portalu Norda Biznes Partner.',
|
||||
email_type='admin_notification',
|
||||
bcc=[]
|
||||
)
|
||||
except Exception as notify_err:
|
||||
logger.warning(f"Failed to send activation notification: {notify_err}")
|
||||
|
||||
flash('Haslo zostalo zmienione. Mozesz sie teraz zalogowac.', 'success')
|
||||
return redirect(url_for('login'))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user