Harshit Ghosh commited on
Commit
353c165
·
1 Parent(s): 20d5ed3

Fix profile bugs: audit log cascade, modal colors, upload icon

Browse files
auth_routes.py CHANGED
@@ -672,9 +672,13 @@ def delete_account():
672
  except Exception as exc:
673
  logger.warning("Failed to delete avatar during account deletion: %s", exc)
674
 
 
 
 
 
675
  db.session.delete(current_user)
676
  db.session.commit()
677
- log_audit('account_deleted', user_id=user_id, status='success')
678
  logout_user()
679
  flash('Your account has been successfully deleted.', 'success')
680
  return redirect(url_for('home'))
 
672
  except Exception as exc:
673
  logger.warning("Failed to delete avatar during account deletion: %s", exc)
674
 
675
+ # Fix foreign key violation: Nullify user_id in audit_logs before deleting user
676
+ from models import AuditLog
677
+ AuditLog.query.filter_by(user_id=user_id).update({'user_id': None})
678
+
679
  db.session.delete(current_user)
680
  db.session.commit()
681
+ log_audit('account_deleted', user_id=None, status='success', details=f"User {user_id} deleted")
682
  logout_user()
683
  flash('Your account has been successfully deleted.', 'success')
684
  return redirect(url_for('home'))
static/css/auth.css CHANGED
@@ -463,11 +463,17 @@
463
  justify-content: center;
464
  padding: 20px;
465
  }
466
- .modal-content {
467
  width: 100%;
468
  max-width: 400px;
 
 
 
469
  animation: modal-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
470
  }
 
 
 
471
  @keyframes modal-pop {
472
  0% { transform: scale(0.95) translateY(10px); opacity: 0; }
473
  100% { transform: scale(1) translateY(0); opacity: 1; }
 
463
  justify-content: center;
464
  padding: 20px;
465
  }
466
+ .profile-modal-content {
467
  width: 100%;
468
  max-width: 400px;
469
+ background-color: #111c33 !important;
470
+ color: #f8fafc !important;
471
+ border: 1px solid #1e293b !important;
472
  animation: modal-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
473
  }
474
+ .profile-modal-content h2, .profile-modal-content label {
475
+ color: #f8fafc;
476
+ }
477
  @keyframes modal-pop {
478
  0% { transform: scale(0.95) translateY(10px); opacity: 0; }
479
  100% { transform: scale(1) translateY(0); opacity: 1; }
templates/auth/profile.html CHANGED
@@ -16,7 +16,7 @@
16
  </div>
17
  {% endif %}
18
  <button class="avatar-upload-btn" onclick="document.getElementById('avatarUpload').click()" title="Change Avatar">
19
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
20
  </button>
21
  <input type="file" id="avatarUpload" accept="image/*" style="display: none;">
22
  </div>
@@ -155,7 +155,7 @@
155
 
156
  <!-- Edit Profile Field Modal -->
157
  <div class="modal-overlay" id="editModal" style="display: none;">
158
- <div class="modal-content auth-card">
159
  <div class="auth-card-header" style="margin-bottom:20px;">
160
  <h2 id="editModalTitle">Edit Field</h2>
161
  </div>
@@ -198,7 +198,7 @@
198
 
199
  <!-- Delete Account Modal -->
200
  <div class="modal-overlay" id="deleteModal" style="display: none;">
201
- <div class="modal-content auth-card">
202
  <div class="auth-card-header" style="margin-bottom:20px;">
203
  <h2 style="color:#ef4444;">Delete Account</h2>
204
  <p style="color:#fca5a5; font-size:13px; margin-top:8px;">This action is permanent and cannot be undone.</p>
 
16
  </div>
17
  {% endif %}
18
  <button class="avatar-upload-btn" onclick="document.getElementById('avatarUpload').click()" title="Change Avatar">
19
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2.5"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
20
  </button>
21
  <input type="file" id="avatarUpload" accept="image/*" style="display: none;">
22
  </div>
 
155
 
156
  <!-- Edit Profile Field Modal -->
157
  <div class="modal-overlay" id="editModal" style="display: none;">
158
+ <div class="profile-modal-content auth-card">
159
  <div class="auth-card-header" style="margin-bottom:20px;">
160
  <h2 id="editModalTitle">Edit Field</h2>
161
  </div>
 
198
 
199
  <!-- Delete Account Modal -->
200
  <div class="modal-overlay" id="deleteModal" style="display: none;">
201
+ <div class="profile-modal-content auth-card">
202
  <div class="auth-card-header" style="margin-bottom:20px;">
203
  <h2 style="color:#ef4444;">Delete Account</h2>
204
  <p style="color:#fca5a5; font-size:13px; margin-top:8px;">This action is permanent and cannot be undone.</p>