password reset
This commit is contained in:
@@ -1420,36 +1420,21 @@ def init_routes(main_bp):
|
||||
return jsonify({'error': 'Unauthorized'}), 403
|
||||
|
||||
event = Event.query.get_or_404(event_id)
|
||||
logger.info(f"Raw event object: {event}")
|
||||
logger.info(f"Event details type: {type(event.details)}")
|
||||
logger.info(f"Event details value: {event.details}")
|
||||
|
||||
# Convert details to dict if it's a string
|
||||
details = event.details
|
||||
if isinstance(details, str):
|
||||
try:
|
||||
import json
|
||||
details = json.loads(details)
|
||||
except json.JSONDecodeError:
|
||||
details = {'raw_details': details}
|
||||
|
||||
# Return the raw event data
|
||||
response_data = {
|
||||
return jsonify({
|
||||
'id': event.id,
|
||||
'event_type': event.event_type,
|
||||
'timestamp': event.timestamp.isoformat(),
|
||||
'details': event.details,
|
||||
'ip_address': event.ip_address,
|
||||
'user_agent': event.user_agent,
|
||||
'user': {
|
||||
'id': event.user.id,
|
||||
'username': event.user.username,
|
||||
'last_name': event.user.last_name
|
||||
} if event.user else None,
|
||||
'ip_address': event.ip_address,
|
||||
'user_agent': event.user_agent,
|
||||
'details': details
|
||||
}
|
||||
|
||||
logger.info(f"Sending response: {response_data}")
|
||||
return jsonify(response_data)
|
||||
'last_name': event.user.last_name,
|
||||
'email': event.user.email
|
||||
} if event.user else None
|
||||
})
|
||||
|
||||
@main_bp.route('/settings/events/download')
|
||||
@login_required
|
||||
@@ -1722,4 +1707,26 @@ def init_routes(main_bp):
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'results': results
|
||||
})
|
||||
|
||||
@main_bp.route('/api/mails/<int:mail_id>')
|
||||
@login_required
|
||||
def get_mail_details(mail_id):
|
||||
if not current_user.is_admin:
|
||||
return jsonify({'error': 'Unauthorized'}), 403
|
||||
|
||||
mail = Mail.query.get_or_404(mail_id)
|
||||
|
||||
return jsonify({
|
||||
'id': mail.id,
|
||||
'recipient': mail.recipient,
|
||||
'subject': mail.subject,
|
||||
'body': mail.body,
|
||||
'status': mail.status,
|
||||
'created_at': mail.created_at.isoformat(),
|
||||
'sent_at': mail.sent_at.isoformat() if mail.sent_at else None,
|
||||
'template': {
|
||||
'id': mail.template.id,
|
||||
'name': mail.template.name
|
||||
} if mail.template else None
|
||||
})
|
||||
Reference in New Issue
Block a user