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
|
Provides REST API endpoints for authentication management
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask import jsonify, request
|
from flask import Blueprint, jsonify, request
|
||||||
import auth_manager
|
import auth_manager
|
||||||
|
|
||||||
|
auth_bp = Blueprint('auth', __name__)
|
||||||
|
|
||||||
def register_auth_routes(app):
|
@auth_bp.route('/api/auth/status', methods=['GET'])
|
||||||
"""Register authentication routes with the Flask app"""
|
def auth_status():
|
||||||
|
|
||||||
@app.route('/api/auth/status', methods=['GET'])
|
|
||||||
def auth_status():
|
|
||||||
"""Get current authentication status"""
|
"""Get current authentication status"""
|
||||||
try:
|
try:
|
||||||
status = auth_manager.get_auth_status()
|
status = auth_manager.get_auth_status()
|
||||||
@@ -20,8 +18,8 @@ def register_auth_routes(app):
|
|||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/auth/setup', methods=['POST'])
|
@auth_bp.route('/api/auth/setup', methods=['POST'])
|
||||||
def auth_setup():
|
def auth_setup():
|
||||||
"""Set up authentication with username and password"""
|
"""Set up authentication with username and password"""
|
||||||
try:
|
try:
|
||||||
data = request.json
|
data = request.json
|
||||||
@@ -38,8 +36,8 @@ def register_auth_routes(app):
|
|||||||
return jsonify({"success": False, "message": str(e)}), 500
|
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():
|
def auth_decline():
|
||||||
"""Decline authentication setup"""
|
"""Decline authentication setup"""
|
||||||
try:
|
try:
|
||||||
success, message = auth_manager.decline_auth()
|
success, message = auth_manager.decline_auth()
|
||||||
@@ -52,8 +50,8 @@ def register_auth_routes(app):
|
|||||||
return jsonify({"success": False, "message": str(e)}), 500
|
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():
|
def auth_login():
|
||||||
"""Authenticate user and return JWT token"""
|
"""Authenticate user and return JWT token"""
|
||||||
try:
|
try:
|
||||||
data = request.json
|
data = request.json
|
||||||
@@ -70,8 +68,8 @@ def register_auth_routes(app):
|
|||||||
return jsonify({"success": False, "message": str(e)}), 500
|
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():
|
def auth_enable():
|
||||||
"""Enable authentication"""
|
"""Enable authentication"""
|
||||||
try:
|
try:
|
||||||
success, message = auth_manager.enable_auth()
|
success, message = auth_manager.enable_auth()
|
||||||
@@ -84,8 +82,8 @@ def register_auth_routes(app):
|
|||||||
return jsonify({"success": False, "message": str(e)}), 500
|
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():
|
def auth_disable():
|
||||||
"""Disable authentication"""
|
"""Disable authentication"""
|
||||||
try:
|
try:
|
||||||
success, message = auth_manager.disable_auth()
|
success, message = auth_manager.disable_auth()
|
||||||
@@ -98,8 +96,8 @@ def register_auth_routes(app):
|
|||||||
return jsonify({"success": False, "message": str(e)}), 500
|
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():
|
def auth_change_password():
|
||||||
"""Change authentication password"""
|
"""Change authentication password"""
|
||||||
try:
|
try:
|
||||||
data = request.json
|
data = request.json
|
||||||
|
|||||||
Reference in New Issue
Block a user