From 80757a6232f5419866613b8d1289b38d77e8aaf9 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Thu, 9 Feb 2023 20:11:17 +0530 Subject: [PATCH] invalidate token --- smart_service/apis/app_user_login.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/smart_service/apis/app_user_login.py b/smart_service/apis/app_user_login.py index 38aa0af..5ffeaaf 100644 --- a/smart_service/apis/app_user_login.py +++ b/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}