From 835e50a9f272eae8ba26d4e6707ffaac61851fa9 Mon Sep 17 00:00:00 2001 From: "ethan.chen" Date: Tue, 27 May 2025 18:08:52 +0800 Subject: [PATCH] feat: add authentication verification endpoint to validate tokens and return user information --- app.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app.py b/app.py index 5526244..291ece8 100644 --- a/app.py +++ b/app.py @@ -31,6 +31,24 @@ def auth_required(f): return f(*args, **kwargs) return decorated +@app.route('/api/auth/verify', methods=['GET']) +@auth_required +def verify_auth(): + try: + return jsonify({ + 'code': 0, + 'data': { + 'username': USERNAME + }, + 'message': 'Token is valid' + }) + except Exception as e: + return jsonify({ + 'code': 1, + 'data': {}, + 'message': str(e) + }), 500 + # 配置数据库 app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///media.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False