added events to event system
This commit is contained in:
@@ -3,7 +3,7 @@ from flask_login import login_user, logout_user, login_required, current_user
|
||||
from models import db, User
|
||||
from functools import wraps
|
||||
from datetime import datetime
|
||||
from utils import log_event
|
||||
from utils import log_event, create_notification
|
||||
|
||||
def require_password_change(f):
|
||||
@wraps(f)
|
||||
@@ -94,6 +94,18 @@ def init_routes(auth_bp):
|
||||
db.session.add(new_user)
|
||||
db.session.commit()
|
||||
|
||||
# Create notification for the new user
|
||||
create_notification(
|
||||
notif_type='account_created',
|
||||
user_id=new_user.id,
|
||||
details={
|
||||
'message': 'Welcome to DocuPulse! Your account has been created successfully.',
|
||||
'username': new_user.username,
|
||||
'email': new_user.email,
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
}
|
||||
)
|
||||
|
||||
# Log successful registration
|
||||
log_event(
|
||||
event_type='user_create',
|
||||
@@ -169,6 +181,16 @@ def init_routes(auth_bp):
|
||||
|
||||
current_user.set_password(new_password)
|
||||
|
||||
# Create password change notification
|
||||
create_notification(
|
||||
notif_type='password_changed',
|
||||
user_id=current_user.id,
|
||||
details={
|
||||
'message': 'Your password has been changed successfully.',
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
}
|
||||
)
|
||||
|
||||
# Log successful password change
|
||||
log_event(
|
||||
event_type='user_update',
|
||||
|
||||
Reference in New Issue
Block a user