Skip to content

Commit 354dd81

Browse files
Update main.py
1 parent 40b67c3 commit 354dd81

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ def delete_forwarder(alias):
180180
print(f"Error deleting forwarder: {e}")
181181
return jsonify({'error': str(e)}), 500
182182

183+
# Add this after creating the app
184+
@app.before_request
185+
def check_session():
186+
"""Ensure session is valid for API routes"""
187+
if request.path.startswith(('/api/', '/settings/api/', '/admin/api/')):
188+
if not current_user.is_authenticated:
189+
return jsonify({'error': 'Authentication required', 'redirect': '/login'}), 401
190+
183191
return app
184192

185193
if __name__ == '__main__':

0 commit comments

Comments
 (0)