|
|
@ -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(''' |
|
|
|