|
@@ -80,14 +80,15 @@ class AuthView(View):
|
|
|
user_qs = GrantCodeModel.objects.filter(userID__userID=userID)
|
|
|
code = CommonService.encrypt_data(randomlength=32)
|
|
|
if client_id == '':
|
|
|
- application = ApplicationModel.objects.filter(grant_type="authorization_code")
|
|
|
+ application = ApplicationModel.objects.filter(redirect_uri=redirect_uri)
|
|
|
+ if application.exists():
|
|
|
+ application = ApplicationModel.objects.filter(grant_type="authorization_code")
|
|
|
else:
|
|
|
application = ApplicationModel.objects.filter(client_id=client_id)
|
|
|
if application.exists():
|
|
|
print(application.exists())
|
|
|
else:
|
|
|
return response.json(10005)
|
|
|
-
|
|
|
if redirect_uri == '':
|
|
|
pass
|
|
|
else:
|
|
@@ -112,7 +113,7 @@ class AuthView(View):
|
|
|
print('在修改')
|
|
|
user_qs.update(code=code, app_id=app_id, update_time=nowTime, expire_time=nowTime+3600)
|
|
|
if state == '':
|
|
|
- state = CommonService.encrypt_data(randomlength=4)
|
|
|
+ state = 'cHpi'
|
|
|
redirect_uri = application[0].redirect_uri + '?code=' + code + '&state=' + state
|
|
|
if application[0].skip_auth:
|
|
|
return HttpResponseRedirect(redirect_uri)
|
|
@@ -234,13 +235,17 @@ class ApplicationView(View):
|
|
|
if line == 0:
|
|
|
line=10
|
|
|
qs = ApplicationModel.objects.all()
|
|
|
- gc = GrantCodeModel.objects.all()
|
|
|
+
|
|
|
if qs.exists():
|
|
|
count = qs.count()
|
|
|
res = qs[(page - 1) * line:page * line]
|
|
|
send_json = CommonService.qs_to_dict(res)
|
|
|
+ for k, v in enumerate(send_json["datas"]):
|
|
|
+ print(send_json['datas'][k]['pk'])
|
|
|
+ gc = GrantCodeModel.objects.filter(application = send_json['datas'][k]['pk'])
|
|
|
+ send_json["datas"][k]['fields']['count_num'] = gc.count()
|
|
|
send_json['count'] = count
|
|
|
- send_json['gc_count'] = gc.count()
|
|
|
+
|
|
|
return response.json(0, send_json)
|
|
|
else:
|
|
|
return response.json(0, {'datas': [], 'count': 0})
|