mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 03:26:17 +00:00
Update flask_auth_routes.py
This commit is contained in:
@@ -3,15 +3,13 @@ Flask Authentication Routes
|
||||
Provides REST API endpoints for authentication management
|
||||
"""
|
||||
|
||||
from flask import jsonify, request
|
||||
from flask import Blueprint, jsonify, request
|
||||
import auth_manager
|
||||
|
||||
auth_bp = Blueprint('auth', __name__)
|
||||
|
||||
def register_auth_routes(app):
|
||||
"""Register authentication routes with the Flask app"""
|
||||
|
||||
@app.route('/api/auth/status', methods=['GET'])
|
||||
def auth_status():
|
||||
@auth_bp.route('/api/auth/status', methods=['GET'])
|
||||
def auth_status():
|
||||
"""Get current authentication status"""
|
||||
try:
|
||||
status = auth_manager.get_auth_status()
|
||||
@@ -20,8 +18,8 @@ def register_auth_routes(app):
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/setup', methods=['POST'])
|
||||
def auth_setup():
|
||||
@auth_bp.route('/api/auth/setup', methods=['POST'])
|
||||
def auth_setup():
|
||||
"""Set up authentication with username and password"""
|
||||
try:
|
||||
data = request.json
|
||||
@@ -38,8 +36,8 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/decline', methods=['POST'])
|
||||
def auth_decline():
|
||||
@auth_bp.route('/api/auth/decline', methods=['POST'])
|
||||
def auth_decline():
|
||||
"""Decline authentication setup"""
|
||||
try:
|
||||
success, message = auth_manager.decline_auth()
|
||||
@@ -52,8 +50,8 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/login', methods=['POST'])
|
||||
def auth_login():
|
||||
@auth_bp.route('/api/auth/login', methods=['POST'])
|
||||
def auth_login():
|
||||
"""Authenticate user and return JWT token"""
|
||||
try:
|
||||
data = request.json
|
||||
@@ -70,8 +68,8 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/enable', methods=['POST'])
|
||||
def auth_enable():
|
||||
@auth_bp.route('/api/auth/enable', methods=['POST'])
|
||||
def auth_enable():
|
||||
"""Enable authentication"""
|
||||
try:
|
||||
success, message = auth_manager.enable_auth()
|
||||
@@ -84,8 +82,8 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/disable', methods=['POST'])
|
||||
def auth_disable():
|
||||
@auth_bp.route('/api/auth/disable', methods=['POST'])
|
||||
def auth_disable():
|
||||
"""Disable authentication"""
|
||||
try:
|
||||
success, message = auth_manager.disable_auth()
|
||||
@@ -98,8 +96,8 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/change-password', methods=['POST'])
|
||||
def auth_change_password():
|
||||
@auth_bp.route('/api/auth/change-password', methods=['POST'])
|
||||
def auth_change_password():
|
||||
"""Change authentication password"""
|
||||
try:
|
||||
data = request.json
|
||||
|
||||
Reference in New Issue
Block a user