Browse Source

invalidate token

master
venkataakhil 2 years ago
parent
commit
80757a6232
  1. 12
      smart_service/apis/app_user_login.py

12
smart_service/apis/app_user_login.py

@ -244,7 +244,6 @@ def grant_user_access(userdata=None, iid=None):
return {'status': 0, 'error': "Failed to Create token"}
else:
frappe.set_user("Administrator")
user = frappe.new_doc('User')
user.email = email
user.first_name = first_name
@ -266,7 +265,7 @@ def grant_user_access(userdata=None, iid=None):
user_name[0]['name'], access_token, refresh_token)
except:
return {'status': 0, 'error': "Failed to Create token"}
frappe.set_user("Administrator")
'''Inserting Dealer Data'''
if frappe.db.exists({'doctype': 'App Dealer', 'dealer_code': dealer_code}):
dealer = frappe.get_doc(
@ -283,7 +282,6 @@ def grant_user_access(userdata=None, iid=None):
{'doctype': 'App Dealer', 'dealer_code': dealer_code})
'''Inserting User data'''
frappe.set_user("Administrator")
app_dealer1 = frappe.get_last_doc(
'App Dealer', filters={"dealer_code": dealer_code})
if frappe.db.exists({'doctype': 'App Users', 'email_id': email}):
@ -304,7 +302,6 @@ def grant_user_access(userdata=None, iid=None):
app_user.save()
'''Inserting Device data'''
frappe.set_user("Administrator")
if iid == 'None' or iid == 'null':
app_device = frappe.new_doc('App Device')
app_device.device_id = device_id
@ -395,7 +392,7 @@ def grant_user_access(userdata=None, iid=None):
app_logs.longitude = longitude
app_logs.date_time_stamp = now()
app_logs.save()
frappe.set_user("Administrator")
lst = frappe.db.sql(
'''SELECT name FROM {}.`tabApp Device` where device_id = "{}" order by name desc limit 1;'''.format(
current_db_name, device_id), as_list=True)
@ -902,11 +899,6 @@ def invalidate_token(refresh_token):
if decrypt(d['refresh_token']) == ref_token:
frappe.delete_doc('Refresh Token', d['name'])
access_token = generate_access_token(d['user'])
# refresh_token = generate_refresh_token()
# token_details = update_tokens_in_doc(
# d['user'], access_token, refresh_token)
# generate_user_token(d['name'])
# generate_access_token(d['name'])
return {'status': 1, "error": None}

Loading…
Cancel
Save