|
7 | 7 | from operator import and_ |
8 | 8 |
|
9 | 9 | from flask import jsonify |
10 | | -from flask_jwt_extended import create_access_token, jwt_refresh_token_required, get_jwt_identity, get_current_user, \ |
11 | | - create_refresh_token |
| 10 | +from flask_jwt_extended import create_access_token, get_jwt_identity, get_current_user, \ |
| 11 | + create_refresh_token, verify_jwt_refresh_token_in_request |
12 | 12 | from lin.core import manager, route_meta, Log |
13 | 13 | from lin.db import db |
14 | | -from lin.exception import NotFound, Success, Failed, RepeatException, ParameterException |
| 14 | +from lin.exception import NotFound, Success, Failed, RepeatException, ParameterException, RefreshException |
15 | 15 | from lin.jwt import login_required, admin_required, get_tokens |
16 | 16 | from lin.log import Logger |
17 | 17 | from lin.redprint import Redprint |
@@ -100,16 +100,23 @@ def get_information(): |
100 | 100 |
|
101 | 101 | @user_api.route('/refresh', methods=['GET']) |
102 | 102 | @route_meta(auth='刷新令牌', module='用户', mount=False) |
103 | | -@jwt_refresh_token_required |
104 | 103 | def refresh(): |
| 104 | + |
| 105 | + try: |
| 106 | + verify_jwt_refresh_token_in_request() |
| 107 | + except Exception: |
| 108 | + return RefreshException() |
| 109 | + |
105 | 110 | identity = get_jwt_identity() |
| 111 | + |
106 | 112 | if identity: |
107 | 113 | access_token = create_access_token(identity=identity) |
108 | 114 | refresh_token = create_refresh_token(identity=identity) |
109 | 115 | return jsonify({ |
110 | 116 | 'access_token': access_token, |
111 | 117 | 'refresh_token': refresh_token |
112 | 118 | }) |
| 119 | + |
113 | 120 | return NotFound(msg='refresh_token未被识别') |
114 | 121 |
|
115 | 122 |
|
|
0 commit comments