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,14 +3,12 @@ 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'])
|
||||
@auth_bp.route('/api/auth/status', methods=['GET'])
|
||||
def auth_status():
|
||||
"""Get current authentication status"""
|
||||
try:
|
||||
@@ -20,7 +18,7 @@ def register_auth_routes(app):
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/setup', methods=['POST'])
|
||||
@auth_bp.route('/api/auth/setup', methods=['POST'])
|
||||
def auth_setup():
|
||||
"""Set up authentication with username and password"""
|
||||
try:
|
||||
@@ -38,7 +36,7 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/decline', methods=['POST'])
|
||||
@auth_bp.route('/api/auth/decline', methods=['POST'])
|
||||
def auth_decline():
|
||||
"""Decline authentication setup"""
|
||||
try:
|
||||
@@ -52,7 +50,7 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/login', methods=['POST'])
|
||||
@auth_bp.route('/api/auth/login', methods=['POST'])
|
||||
def auth_login():
|
||||
"""Authenticate user and return JWT token"""
|
||||
try:
|
||||
@@ -70,7 +68,7 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/enable', methods=['POST'])
|
||||
@auth_bp.route('/api/auth/enable', methods=['POST'])
|
||||
def auth_enable():
|
||||
"""Enable authentication"""
|
||||
try:
|
||||
@@ -84,7 +82,7 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/disable', methods=['POST'])
|
||||
@auth_bp.route('/api/auth/disable', methods=['POST'])
|
||||
def auth_disable():
|
||||
"""Disable authentication"""
|
||||
try:
|
||||
@@ -98,7 +96,7 @@ def register_auth_routes(app):
|
||||
return jsonify({"success": False, "message": str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/auth/change-password', methods=['POST'])
|
||||
@auth_bp.route('/api/auth/change-password', methods=['POST'])
|
||||
def auth_change_password():
|
||||
"""Change authentication password"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user