12
12
import http .client as http_client
13
13
import json
14
14
import logging
15
+
15
16
import marshmallow as ma
17
+ from drift .blueprint import Blueprint , abort
18
+ from drift .core .extensions .jwt import current_user , issue_token
19
+ from drift .core .extensions .jwt import split_token
20
+ from drift .core .extensions .urlregistry import Endpoints
21
+ from drift .utils import json_response
16
22
from flask import request , url_for , g , current_app
17
23
from flask .views import MethodView
18
- from drift .blueprint import Blueprint , abort
19
24
from flask_marshmallow .fields import AbsoluteURLFor
20
25
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
21
26
22
- from driftbase .richpresence import RichPresenceService
23
-
24
- from drift .core .extensions .jwt import current_user , issue_token
25
- from drift .core .extensions .urlregistry import Endpoints
26
- from drift .utils import json_response
27
27
from driftbase .config import get_client_heartbeat_config
28
28
from driftbase .models .db import (
29
29
User , CorePlayer , Client , UserIdentity
30
30
)
31
+ from driftbase .richpresence import RichPresenceService
31
32
from driftbase .utils import url_client
32
33
33
34
log = logging .getLogger (__name__ )
@@ -66,8 +67,8 @@ class Meta:
66
67
exclude = ()
67
68
68
69
client_url = AbsoluteURLFor ('clients.entry' ,
69
- doc = "Fully qualified URL of the client resource" ,
70
- client_id = '<client_id>' )
70
+ doc = "Fully qualified URL of the client resource" ,
71
+ client_id = '<client_id>' )
71
72
72
73
73
74
class ClientPostRequestSchema (ma .Schema ):
@@ -206,14 +207,9 @@ def post(self, args):
206
207
payload = dict (current_user )
207
208
payload ["client_id" ] = client_id
208
209
new_token = issue_token (payload )
209
-
210
- jwt = new_token ["token" ]
211
- jti = new_token ['payload' ]["jti" ]
210
+ _ , token = split_token (new_token ["token" ])
212
211
213
212
resource_url = url_client (client_id )
214
- response_header = {
215
- "Location" : resource_url ,
216
- }
217
213
log .info ("Client %s for user %s / player %s has been registered" ,
218
214
client_id , user_id , player_id )
219
215
heartbeat_period , heartbeat_timeout = get_client_heartbeat_config ()
@@ -225,8 +221,8 @@ def post(self, args):
225
221
"server_time" : utcnow (),
226
222
"next_heartbeat_seconds" : heartbeat_period ,
227
223
"heartbeat_timeout" : utcnow () + datetime .timedelta (seconds = heartbeat_timeout ),
228
- "jti" : jti ,
229
- "jwt" : jwt ,
224
+ "jti" : token ,
225
+ "jwt" : token ,
230
226
}
231
227
232
228
message_data = {
0 commit comments