...
|
...
|
@@ -8,6 +8,7 @@ from .oauth2 import authorization, require_oauth, generate_user_info |
8
|
8
|
from authlib.oauth2 import OAuth2Error
|
9
|
9
|
from authlib.integrations.flask_oauth2 import current_token
|
10
|
10
|
|
|
11
|
+
|
11
|
12
|
def current_user():
|
12
|
13
|
if 'id' in session:
|
13
|
14
|
uid = session['id']
|
...
|
...
|
@@ -34,7 +35,7 @@ class DataManager(BlueprintApi): |
34
|
35
|
|
35
|
36
|
@staticmethod
|
36
|
37
|
@bp.route('/', methods=('GET', 'POST'))
|
37
|
|
- def test():
|
|
38
|
+ def Login():
|
38
|
39
|
if request.method == 'POST':
|
39
|
40
|
username = request.form['username']
|
40
|
41
|
password = request.form['password']
|
...
|
...
|
@@ -52,8 +53,6 @@ class DataManager(BlueprintApi): |
52
|
53
|
else:
|
53
|
54
|
clients = []
|
54
|
55
|
return render_template('auth/login.html', user=user, clients=clients)
|
55
|
|
-
|
56
|
|
-
|
57
|
56
|
|
58
|
57
|
@staticmethod
|
59
|
58
|
@bp.route('/create_client', methods=('GET', 'POST'))
|
...
|
...
|
@@ -85,7 +84,7 @@ class DataManager(BlueprintApi): |
85
|
84
|
db.session.add(client)
|
86
|
85
|
db.session.commit()
|
87
|
86
|
return redirect('/auth')
|
88
|
|
-
|
|
87
|
+
|
89
|
88
|
@staticmethod
|
90
|
89
|
@bp.route('/authorize', methods=('GET', 'POST'))
|
91
|
90
|
def authorize():
|
...
|
...
|
@@ -104,13 +103,12 @@ class DataManager(BlueprintApi): |
104
|
103
|
else:
|
105
|
104
|
grant_user = None
|
106
|
105
|
return authorization.create_authorization_response(grant_user=grant_user)
|
107
|
|
-
|
108
|
|
-
|
|
106
|
+
|
109
|
107
|
@staticmethod
|
110
|
108
|
@bp.route('/token', methods=['POST'])
|
111
|
109
|
def issue_token():
|
112
|
110
|
return authorization.create_token_response()
|
113
|
|
-
|
|
111
|
+
|
114
|
112
|
@staticmethod
|
115
|
113
|
@bp.route('/userinfo')
|
116
|
114
|
@require_oauth('profile')
|
...
|
...
|
|