|
@@ -79,39 +79,34 @@ class AuthView(View):
|
|
|
nowTime = int(time.time())
|
|
|
user_qs = GrantCodeModel.objects.filter(userID__userID=userID)
|
|
|
code = CommonService.encrypt_data(randomlength=32)
|
|
|
- if client_id == '':
|
|
|
- application = ApplicationModel.objects.filter(redirect_uri=redirect_uri)
|
|
|
- if application.exists():
|
|
|
- application = ApplicationModel.objects.filter(grant_type="authorization_code")
|
|
|
+ application = ApplicationModel.objects.filter(client_id=client_id)
|
|
|
+ if application.exists():
|
|
|
+ print(application.exists())
|
|
|
else:
|
|
|
- application = ApplicationModel.objects.filter(client_id=client_id)
|
|
|
- if application.exists():
|
|
|
- print(application.exists())
|
|
|
- else:
|
|
|
- return response.json(10005)
|
|
|
+ return response.json(10005)
|
|
|
if redirect_uri == '':
|
|
|
pass
|
|
|
else:
|
|
|
if application[0].redirect_uri != redirect_uri:
|
|
|
return response.json(10006)
|
|
|
- if not user_qs.exists():
|
|
|
+ if user_qs.exists():
|
|
|
+ print('在修改')
|
|
|
+ user_qs.update(code=code, app_id=app_id, update_time=nowTime, expire_time=nowTime + 3600)
|
|
|
+ else:
|
|
|
print('在创建')
|
|
|
try:
|
|
|
grantcode = GrantCodeModel(
|
|
|
userID=Device_User.objects.get(userID=userID),
|
|
|
- application=application,
|
|
|
+ application=ApplicationModel.objects.get(client_id=client_id),
|
|
|
code=code,
|
|
|
app_id=app_id,
|
|
|
- expire_time=nowTime+3600,
|
|
|
+ expire_time=nowTime + 3600,
|
|
|
add_time=nowTime,
|
|
|
update_time=nowTime)
|
|
|
grantcode.save()
|
|
|
except Exception as e:
|
|
|
print(repr(e))
|
|
|
return response.json(178)
|
|
|
- else:
|
|
|
- print('在修改')
|
|
|
- user_qs.update(code=code, app_id=app_id, update_time=nowTime, expire_time=nowTime+3600)
|
|
|
if state == '':
|
|
|
state = 'cHpi'
|
|
|
redirect_uri = application[0].redirect_uri + '?code=' + code + '&state=' + state
|