Sam-max1 commited on
Commit
ea97aeb
·
verified ·
1 Parent(s): 26a84f0

Seamless deployment update for recdgp88 yearbook directory app

Browse files
Files changed (2) hide show
  1. app.py +8 -0
  2. app/templates/base.html +2 -0
app.py CHANGED
@@ -1042,6 +1042,9 @@ def require_admin(f):
1042
  def index():
1043
  if 'userid' in session and session.get('verified_2fa'):
1044
  user_id = session.get('userid')
 
 
 
1045
  with DatabaseManager.get_structured_connection() as conn:
1046
  cursor = conn.cursor()
1047
  cursor.execute("SELECT 1 FROM alumni WHERE alumni_id = ?", (user_id,))
@@ -1888,6 +1891,11 @@ def profile(alumni_id):
1888
  # RBAC constraint: A regular alumnus user can only view/edit their own profile
1889
  current_userid = session.get('userid')
1890
  is_admin = session.get('is_admin')
 
 
 
 
 
1891
 
1892
  if not is_admin and current_userid != alumni_id:
1893
  abort(403)
 
1042
  def index():
1043
  if 'userid' in session and session.get('verified_2fa'):
1044
  user_id = session.get('userid')
1045
+ # 'admin' superuser has no alumni profile — always go to admin dashboard
1046
+ if user_id == 'admin':
1047
+ return redirect(url_for('admin'))
1048
  with DatabaseManager.get_structured_connection() as conn:
1049
  cursor = conn.cursor()
1050
  cursor.execute("SELECT 1 FROM alumni WHERE alumni_id = ?", (user_id,))
 
1891
  # RBAC constraint: A regular alumnus user can only view/edit their own profile
1892
  current_userid = session.get('userid')
1893
  is_admin = session.get('is_admin')
1894
+
1895
+ # The 'admin' superuser account has no alumni profile — redirect to admin dashboard
1896
+ if alumni_id == 'admin' or current_userid == 'admin':
1897
+ flash("The admin account does not have a member profile.", "info")
1898
+ return redirect(url_for('admin'))
1899
 
1900
  if not is_admin and current_userid != alumni_id:
1901
  abort(403)
app/templates/base.html CHANGED
@@ -29,7 +29,9 @@
29
  </div>
30
  <nav>
31
  {% if session.get('userid') %}
 
32
  <a href="{{ url_for('profile', alumni_id=session.get('userid')) }}" class="{% if request.path == url_for('profile', alumni_id=session.get('userid')) %}active{% endif %}">👤 My Profile</a>
 
33
  {% if session.get('is_admin') %}
34
  <a href="{{ url_for('admin') }}" class="{% if request.path == url_for('admin') %}active{% endif %}">🛡️ Admin Dashboard</a>
35
  {% endif %}
 
29
  </div>
30
  <nav>
31
  {% if session.get('userid') %}
32
+ {% if session.get('userid') != 'admin' %}
33
  <a href="{{ url_for('profile', alumni_id=session.get('userid')) }}" class="{% if request.path == url_for('profile', alumni_id=session.get('userid')) %}active{% endif %}">👤 My Profile</a>
34
+ {% endif %}
35
  {% if session.get('is_admin') %}
36
  <a href="{{ url_for('admin') }}" class="{% if request.path == url_for('admin') %}active{% endif %}">🛡️ Admin Dashboard</a>
37
  {% endif %}