22 lines
731 B
Python
22 lines
731 B
Python
from pathlib import Path
|
|
from flask import Blueprint, redirect, flash
|
|
from auth import require_level
|
|
from config_utils import queued_msg, CONFIGS_DIR
|
|
|
|
_PAGE = Path(__file__).parent.name
|
|
|
|
bp = Blueprint(_PAGE, __name__)
|
|
|
|
RADIUS_SECRET_FILE = Path(CONFIGS_DIR) / '.radius-secret'
|
|
|
|
|
|
@bp.route('/action/radius/regenerate', methods=['POST'])
|
|
@require_level('administrator')
|
|
def regenerate():
|
|
try:
|
|
RADIUS_SECRET_FILE.unlink(missing_ok=True)
|
|
except OSError as ex:
|
|
flash(f'Could not delete .radius-secret: {ex}', 'error')
|
|
return redirect(f'/{_PAGE}')
|
|
flash(queued_msg('core apply', action_label='Secret deleted - new secret will be generated on next apply'), 'success')
|
|
return redirect(f'/{_PAGE}')
|