|
|
@ -244,6 +244,7 @@ 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 |
|
|
@ -265,7 +266,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( |
|
|
@ -282,6 +283,7 @@ 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}): |
|
|
@ -302,6 +304,7 @@ 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 |
|
|
@ -392,7 +395,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) |
|
|
@ -898,7 +901,12 @@ def invalidate_token(refresh_token): |
|
|
|
for d in doc_details: |
|
|
|
if decrypt(d['refresh_token']) == ref_token: |
|
|
|
frappe.delete_doc('Refresh Token', d['name']) |
|
|
|
generate_access_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} |
|
|
|
|
|
|
|