feat: add authentication verification endpoint to validate tokens and return user information
This commit is contained in:
18
app.py
18
app.py
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user