Browse Source

data invalidation for logout

master
venkataakhil 1 year ago
parent
commit
d77ed85e7a
  1. 24
      smart_service/apis/app_user_login.py
  2. 18
      smart_service/apis/master_api.py

24
smart_service/apis/app_user_login.py

@ -414,6 +414,30 @@ def grant_user_access(userdata=None, iid=None):
except Exception as e1: except Exception as e1:
return {'status': 0, 'error': "Invalid Inputs"} return {'status': 0, 'error': "Invalid Inputs"}
@frappe.whitelist(allow_guest=True)
def data_invalidation(email, device_id, iid=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
try:
# User validation
frappe.set_user("Administrator")
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
token_details = []
if user_name:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
return {'status': 1, 'data': token_details, 'error': None}
except Exception as e1:
return {'status': 0, 'data': [], 'error': 'Failed to verify user'}
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None): def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):

18
smart_service/apis/master_api.py

@ -296,3 +296,21 @@ def check_pub_type(iid):
if not device_pub_type: if not device_pub_type:
return False return False
return device_pub_type[0][0] return device_pub_type[0][0]
@frappe.whitelist(methods=['POST'])
def variant(LSD):
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":
try:
datetime.datetime.strptime(LSD, date_format)
except:
return {"status": 0, "error": " 'LSD' format error"}
try:
data = frappe.db.sql('''
select v.myid as variant_id,vm.name,vm.vehicle,vm.variant,vm.fuel,vm.transmission,vm.drive,vm.active_status
FROM `tabVariant Mapping` vm left join tabVariant v on v.name = vm.variant where vm.modified >='';''', as_dict=1)
return {"status": 1, "error": None, 'data': data}
except Exception as e:
frappe.local.response['http_status_code'] = 400
return {"status": 0, "error": e, 'data': None}
Loading…
Cancel
Save