feat: add real-time HTTPS status detection on admin config page
- Detect actual HTTPS status from current request (scheme + X-Forwarded-Proto) - Auto-sync database when HTTPS status mismatch is detected - Show real-time connection info (protocol, host, port) - Display helpful message when accessing via HTTPS but config shows disabled - Add CSS styling for detection status display - Users now see accurate HTTPS status even if database wasn't in sync
This commit is contained in:
16
app/blueprints/admin.py
Executable file → Normal file
16
app/blueprints/admin.py
Executable file → Normal file
@@ -858,8 +858,22 @@ def https_config():
|
||||
try:
|
||||
config = HTTPSConfig.get_config()
|
||||
|
||||
# Detect actual current HTTPS status
|
||||
# Check if current connection is HTTPS
|
||||
is_https_active = request.scheme == 'https' or request.headers.get('X-Forwarded-Proto') == 'https'
|
||||
current_host = request.host.split(':')[0] # Remove port if present
|
||||
|
||||
# If HTTPS is active but database shows disabled, sync it
|
||||
if is_https_active and config and not config.https_enabled:
|
||||
# Update database to reflect actual HTTPS status
|
||||
config.https_enabled = True
|
||||
db.session.commit()
|
||||
log_action('info', f'HTTPS status auto-corrected to enabled (detected from request)')
|
||||
|
||||
return render_template('admin/https_config.html',
|
||||
config=config)
|
||||
config=config,
|
||||
is_https_active=is_https_active,
|
||||
current_host=current_host)
|
||||
except Exception as e:
|
||||
log_action('error', f'Error loading HTTPS config page: {str(e)}')
|
||||
flash('Error loading HTTPS configuration page.', 'danger')
|
||||
|
||||
Reference in New Issue
Block a user