|
|
@ -10,7 +10,7 @@ from cryptography.fernet import Fernet, InvalidToken |
|
|
|
from frappe.utils import cstr, encode |
|
|
|
from datetime import datetime |
|
|
|
from datetime import timedelta |
|
|
|
from smart_service.apis.master_api import rate_limit |
|
|
|
from smart_service.apis.master_api import custom_rate_limit |
|
|
|
|
|
|
|
current_db_name = frappe.conf.get("db_name") |
|
|
|
|
|
|
@ -30,7 +30,7 @@ def app_user_validation_test(): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=True) |
|
|
|
def app_user_validation(usr=None, pwd=None): |
|
|
|
# rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
# rate_res = custom_custom_rate_limit(limit=5, seconds=15) |
|
|
|
# if rate_res != 1: |
|
|
|
# return rate_res |
|
|
|
val = input_validation(usr=usr, pwd=pwd) |
|
|
@ -177,7 +177,7 @@ def app_user_validation(usr=None, pwd=None): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=True) |
|
|
|
def grant_user_access(userdata=None, iid=None): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
val = input_validation(userdata=userdata, iid=iid) |
|
|
@ -399,7 +399,7 @@ def grant_user_access(userdata=None, iid=None): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=True) |
|
|
|
def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
val = input_validation(usr=usr, pwd=pwd, iid=iid, device_data=device_data) |
|
|
@ -540,7 +540,7 @@ def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None): |
|
|
|
|
|
|
|
|
|
|
|
def new_grant_user_access(userdata=None, iid=None): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
try: |
|
|
@ -751,7 +751,7 @@ def new_grant_user_access(userdata=None, iid=None): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=1) |
|
|
|
def generate_keys(user_name): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
|
|
|
@ -769,7 +769,7 @@ def generate_keys(user_name): |
|
|
|
|
|
|
|
@frappe.whitelist() |
|
|
|
def login_generate_token(doc=None, method=None): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
new_tok = generate_keys('cms@guidedsmartservice.com') |
|
|
@ -798,7 +798,7 @@ def xml_to_dict(node): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=True) |
|
|
|
def generate_user_token(user_email): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
access_token = generate_access_token(user_email) |
|
|
@ -810,7 +810,7 @@ def generate_user_token(user_email): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=True) |
|
|
|
def generate_access_token(user_email): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
frappe.set_user("Administrator") |
|
|
@ -839,7 +839,7 @@ def generate_refresh_token(): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=1, methods=['POST']) |
|
|
|
def refresh_token(refresh_token): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
if refresh_token: |
|
|
@ -871,7 +871,7 @@ def refresh_token(refresh_token): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=1, methods=['POST']) |
|
|
|
def invalidate_token(refresh_token): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
if refresh_token: |
|
|
@ -964,7 +964,7 @@ def get_encryption_key(): |
|
|
|
|
|
|
|
@frappe.whitelist(allow_guest=1) |
|
|
|
def deactivate_tokens(): |
|
|
|
rate_res = rate_limit(limit=5, seconds=15) |
|
|
|
rate_res = custom_rate_limit(limit=5, seconds=15) |
|
|
|
if rate_res != 1: |
|
|
|
return rate_res |
|
|
|
frappe.set_user("Administrator") |
|
|
|