账号密码登录,签发 access/refresh JWT。
()
| 1514 | |
| 1515 | @app.route('/api/auth/login', methods=['POST']) |
| 1516 | def 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']) |
nothing calls this directly
no test coverage detected