Browse Source

Deactivate account

master
venkataakhil 1 year ago
parent
commit
c7711518b3
  1. 31
      smart_service/apis/app_user_login.py
  2. 3
      smart_service/transactions/report/audit_report/audit_report.py

31
smart_service/apis/app_user_login.py

@ -1001,7 +1001,36 @@ def deactivate_tokens():
token_settings = frappe.get_doc('Token Settings')
access_exp_hours = token_settings.access_expiry_time
# access_exp_hours = 15 * 60
access_exp_time = datetime.now() + timedelta(minutes=access_exp_hours)
frappe.set_user("Administrator")
doc_details = frappe.db.sql('''
SELECT * FROM `tabRefresh Token`;''', as_dict=1)
try:
cur_time = datetime.now()
for d in doc_details:
if d['access_expiry_time'] < cur_time:
doc_value = frappe.get_doc('Refresh Token', d['name'])
doc_value.access_token = encrypt(generate_keys(d['user']))
doc_value.access_expiry_time = access_exp_time
doc_value.save()
if d['refresh_expiry_time'] < cur_time:
frappe.delete_doc('Refresh Token', d['name'])
return True
except Exception as e:
return e
@frappe.whitelist(allow_guest=1)
def deactivate_account():
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
token_settings = frappe.get_doc('Token Settings')
access_exp_hours = token_settings.access_expiry_time
access_exp_time = datetime.now() + timedelta(minutes=access_exp_hours)
frappe.set_user("Administrator")
doc_details = frappe.db.sql('''

3
smart_service/transactions/report/audit_report/audit_report.py

@ -16,7 +16,10 @@ activeStatusQuerycase= "case when active_status = 'Active' then 'A' else 'IA' en
def execute(filters=None):
data = getData(filters)
if not data:
data = []
columns = getColumns()
return columns, data

Loading…
Cancel
Save