diff --git a/blueprints/auth/routes.py b/blueprints/auth/routes.py index ea4d253..d1f4627 100644 --- a/blueprints/auth/routes.py +++ b/blueprints/auth/routes.py @@ -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'))