feat: add authentication verification endpoint to validate tokens and return user information

This commit is contained in:
ethan.chen
2025-05-27 18:08:52 +08:00
parent bef83f655c
commit 835e50a9f2

18
app.py
View File

@@ -31,6 +31,24 @@ def auth_required(f):
return f(*args, **kwargs) return f(*args, **kwargs)
return decorated 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_DATABASE_URI'] = 'sqlite:///media.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False