mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 11:36: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
|
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"""
|
|
||||||
|
|
||||||
@app.route('/api/auth/status', methods=['GET'])
|
|
||||||
def auth_status():
|
def auth_status():
|
||||||
"""Get current authentication status"""
|
"""Get current authentication status"""
|
||||||
try:
|
try:
|
||||||
@@ -20,7 +18,7 @@ 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:
|
||||||
@@ -38,7 +36,7 @@ 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:
|
||||||
@@ -52,7 +50,7 @@ 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:
|
||||||
@@ -70,7 +68,7 @@ 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:
|
||||||
@@ -84,7 +82,7 @@ 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:
|
||||||
@@ -98,7 +96,7 @@ 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:
|
||||||
|
|||||||
Reference in New Issue
Block a user