MCPcopy Create free account
hub / github.com/Tong89/smartNode / auth_login

Function auth_login

backend/api.py:1516–1528  ·  view source on GitHub ↗

账号密码登录,签发 access/refresh JWT。

()

Source from the content-addressed store, hash-verified

1514
1515@app.route('/api/auth/login', methods=['POST'])
1516def auth_login():
1517 """账号密码登录,签发 access/refresh JWT。"""
1518 data = request.get_json(silent=True) or {}
1519 role = authenticate_user(data.get('username'), data.get('password'))
1520 if not role:
1521 return error_response("UNAUTHORIZED", "用户名或密码错误")
1522 sub = data.get('username')
1523 return jsonify({
1524 'token_type': 'Bearer',
1525 'access_token': create_access_token(sub, role),
1526 'refresh_token': create_refresh_token(sub, role),
1527 'role': role,
1528 })
1529
1530
1531@app.route('/api/auth/refresh', methods=['POST'])

Callers

nothing calls this directly

Calls 5

authenticate_userFunction · 0.90
error_responseFunction · 0.90
create_access_tokenFunction · 0.90
create_refresh_tokenFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected