22 lines
704 B
Python
22 lines
704 B
Python
from pathlib import Path
|
|
from flask import Blueprint, redirect, flash
|
|
from auth import require_level
|
|
from config_utils import 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('Secret deleted. A new secret will be generated when the pending command is applied.', 'success')
|
|
return redirect(f'/{_PAGE}')
|