|
|
@ -10,21 +10,9 @@ from copy import copy |
|
|
|
|
|
|
|
current_db_name = frappe.conf.get("db_name") |
|
|
|
|
|
|
|
|
|
|
|
# Temporary Login |
|
|
|
@frappe.whitelist(allow_guest=True) |
|
|
|
def app_user_validation(usr=None, pwd=None): |
|
|
|
if usr == None and pwd == None: |
|
|
|
return {'status': 0, 'error': "Parameter's missing: Usr & pwd"} |
|
|
|
if usr == None: |
|
|
|
return {'status': 0, 'error': "Parameter missing: Usr"} |
|
|
|
if pwd == None: |
|
|
|
return {'status': 0, 'error': "Parameter missing: Pwd"} |
|
|
|
|
|
|
|
preference = frappe.get_last_doc('App Preference') |
|
|
|
mahindra_login = preference.mahindra_login_api |
|
|
|
technician_login = preference.technician_login_api |
|
|
|
|
|
|
|
# Temporary Login |
|
|
|
def app_user_validation(): |
|
|
|
dicData= {} |
|
|
|
try: |
|
|
|
doc = frappe.get_doc("Fish", None) |
|
|
@ -33,141 +21,154 @@ def app_user_validation(usr=None, pwd=None): |
|
|
|
except: |
|
|
|
return {'status': 0, 'error': 'Site Error'} |
|
|
|
return dicData |
|
|
|
|
|
|
|
# try: |
|
|
|
# data = {'LoginID': usr, 'Password': pwd} |
|
|
|
# headers = {"Content-Type": "application/x-www-form-urlencoded"} |
|
|
|
# if technician_login == 1 and mahindra_login == 0: |
|
|
|
# response = requests.post( |
|
|
|
# "http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers) |
|
|
|
# decoded = response.content.decode('utf-8') |
|
|
|
|
|
|
|
# if len(decoded) > 165: |
|
|
|
# da = re.search("{", decoded) |
|
|
|
# da1 = re.search("}", decoded) |
|
|
|
# trunData = decoded[da.span()[0]:da1.span()[1]] |
|
|
|
# dicData = json.loads(trunData) |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
|
|
|
|
# return dicData |
|
|
|
# else: |
|
|
|
# return {'status': 0, 'error': 'Invalid Credentials'} |
|
|
|
|
|
|
|
# elif technician_login == 0 and mahindra_login == 1: |
|
|
|
# response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential", |
|
|
|
# data=data, headers=headers) |
|
|
|
# decoded1 = response1.content.decode('utf-8') |
|
|
|
# node = ET.fromstring(decoded1) |
|
|
|
# dictValue = xml_to_dict(node) |
|
|
|
|
|
|
|
# dicData = { |
|
|
|
# "ID": "{}@email.com".format(usr), |
|
|
|
# "LoginName": usr, |
|
|
|
# "FirstName": "", |
|
|
|
# "LastName": "", |
|
|
|
# "IsActive": "True", |
|
|
|
# "UserType": "", |
|
|
|
# "SkillID": "", |
|
|
|
# "SkillName": "", |
|
|
|
# "UserTypeDesc": "", |
|
|
|
# "PasswordChanged": "", |
|
|
|
# "AreaName": "", |
|
|
|
# "Zone": "", |
|
|
|
# "Code": "", |
|
|
|
# "LocationName": "", |
|
|
|
# "ChannelNo": "", |
|
|
|
# "ServerDate": "", |
|
|
|
# "ServerTime": "", |
|
|
|
# "DealerName": "", |
|
|
|
# "EmailId": "{}@email.com".format(usr), |
|
|
|
# "isLDAPAuthenticated": ""} |
|
|
|
|
|
|
|
# success_msg = None |
|
|
|
# user_name = None |
|
|
|
# msgDic = {} |
|
|
|
|
|
|
|
# try: |
|
|
|
# msgDic['UserName'] = dictValue['children']['UserName']['text'] |
|
|
|
# msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text'] |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
# return dicData |
|
|
|
|
|
|
|
# except: |
|
|
|
# msgDic['IsSuccessfull'] = node.text |
|
|
|
# return {'status': 0, 'error': 'Invalid Credentials'} |
|
|
|
|
|
|
|
# elif technician_login == 1 and mahindra_login == 1: |
|
|
|
# response = requests.post( |
|
|
|
# "http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers) |
|
|
|
# decoded = response.content.decode('utf-8') |
|
|
|
|
|
|
|
# response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential", |
|
|
|
# data=data, headers=headers) |
|
|
|
# decoded1 = response1.content.decode('utf-8') |
|
|
|
# node = ET.fromstring(decoded1) |
|
|
|
# dictValue = xml_to_dict(node) |
|
|
|
|
|
|
|
# dicData = { |
|
|
|
# "ID": "", |
|
|
|
# "LoginName": usr, |
|
|
|
# "FirstName": usr, |
|
|
|
# "LastName": "", |
|
|
|
# "IsActive": "True", |
|
|
|
# "UserType": "", |
|
|
|
# "SkillID": "", |
|
|
|
# "SkillName": "", |
|
|
|
# "UserTypeDesc": "Mahindra User", |
|
|
|
# "PasswordChanged": "", |
|
|
|
# "AreaName": "Mahindra", |
|
|
|
# "Zone": "Mahindra", |
|
|
|
# "LocationName": "Mahindra", |
|
|
|
# "ChannelNo": "", |
|
|
|
# "ServerDate": "", |
|
|
|
# "ServerTime": "", |
|
|
|
# "DealerName": "Mahindra", |
|
|
|
# "EmailId": "{}@mahindra.com".format(usr), |
|
|
|
# "isLDAPAuthenticated": ""} |
|
|
|
|
|
|
|
# success_msg = None |
|
|
|
# user_name = None |
|
|
|
# msgDic = {} |
|
|
|
# if len(decoded) > 165: |
|
|
|
# da = re.search("{", decoded) |
|
|
|
# da1 = re.search("}", decoded) |
|
|
|
# trunData = decoded[da.span()[0]:da1.span()[1]] |
|
|
|
# dicData = json.loads(trunData) |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
|
|
|
|
# return dicData |
|
|
|
|
|
|
|
# @frappe.whitelist(allow_guest=True) |
|
|
|
# def app_user_validation(usr=None, pwd=None): |
|
|
|
# if usr == None and pwd == None: |
|
|
|
# return {'status': 0, 'error': "Parameter's missing: Usr & pwd"} |
|
|
|
# if usr == None: |
|
|
|
# return {'status': 0, 'error': "Parameter missing: Usr"} |
|
|
|
# if pwd == None: |
|
|
|
# return {'status': 0, 'error': "Parameter missing: Pwd"} |
|
|
|
|
|
|
|
# preference = frappe.get_last_doc('App Preference') |
|
|
|
# mahindra_login = preference.mahindra_login_api |
|
|
|
# technician_login = preference.technician_login_api |
|
|
|
|
|
|
|
# try: |
|
|
|
# data = {'LoginID': usr, 'Password': pwd} |
|
|
|
# headers = {"Content-Type": "application/x-www-form-urlencoded"} |
|
|
|
# if technician_login == 1 and mahindra_login == 0: |
|
|
|
# response = requests.post( |
|
|
|
# "http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers) |
|
|
|
# decoded = response.content.decode('utf-8') |
|
|
|
|
|
|
|
# if len(decoded) > 165: |
|
|
|
# da = re.search("{", decoded) |
|
|
|
# da1 = re.search("}", decoded) |
|
|
|
# trunData = decoded[da.span()[0]:da1.span()[1]] |
|
|
|
# dicData = json.loads(trunData) |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
|
|
|
|
# return dicData |
|
|
|
# else: |
|
|
|
# return {'status': 0, 'error': 'Invalid Credentials'} |
|
|
|
|
|
|
|
# elif technician_login == 0 and mahindra_login == 1: |
|
|
|
# response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential", |
|
|
|
# data=data, headers=headers) |
|
|
|
# decoded1 = response1.content.decode('utf-8') |
|
|
|
# node = ET.fromstring(decoded1) |
|
|
|
# dictValue = xml_to_dict(node) |
|
|
|
|
|
|
|
# dicData = { |
|
|
|
# "ID": "{}@email.com".format(usr), |
|
|
|
# "LoginName": usr, |
|
|
|
# "FirstName": "", |
|
|
|
# "LastName": "", |
|
|
|
# "IsActive": "True", |
|
|
|
# "UserType": "", |
|
|
|
# "SkillID": "", |
|
|
|
# "SkillName": "", |
|
|
|
# "UserTypeDesc": "", |
|
|
|
# "PasswordChanged": "", |
|
|
|
# "AreaName": "", |
|
|
|
# "Zone": "", |
|
|
|
# "Code": "", |
|
|
|
# "LocationName": "", |
|
|
|
# "ChannelNo": "", |
|
|
|
# "ServerDate": "", |
|
|
|
# "ServerTime": "", |
|
|
|
# "DealerName": "", |
|
|
|
# "EmailId": "{}@email.com".format(usr), |
|
|
|
# "isLDAPAuthenticated": ""} |
|
|
|
|
|
|
|
# success_msg = None |
|
|
|
# user_name = None |
|
|
|
# msgDic = {} |
|
|
|
|
|
|
|
# try: |
|
|
|
# msgDic['UserName'] = dictValue['children']['UserName']['text'] |
|
|
|
# msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text'] |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
# return dicData |
|
|
|
|
|
|
|
# except: |
|
|
|
# msgDic['IsSuccessfull'] = node.text |
|
|
|
# return {'status': 0, 'error': 'Invalid Credentials'} |
|
|
|
|
|
|
|
# elif technician_login == 1 and mahindra_login == 1: |
|
|
|
# response = requests.post( |
|
|
|
# "http://www.mahindramile.com/ISmartAuth/Service.asmx/ValidateCredential", data=data, headers=headers) |
|
|
|
# decoded = response.content.decode('utf-8') |
|
|
|
|
|
|
|
# response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential", |
|
|
|
# data=data, headers=headers) |
|
|
|
# decoded1 = response1.content.decode('utf-8') |
|
|
|
# node = ET.fromstring(decoded1) |
|
|
|
# dictValue = xml_to_dict(node) |
|
|
|
|
|
|
|
# dicData = { |
|
|
|
# "ID": "", |
|
|
|
# "LoginName": usr, |
|
|
|
# "FirstName": usr, |
|
|
|
# "LastName": "", |
|
|
|
# "IsActive": "True", |
|
|
|
# "UserType": "", |
|
|
|
# "SkillID": "", |
|
|
|
# "SkillName": "", |
|
|
|
# "UserTypeDesc": "Mahindra User", |
|
|
|
# "PasswordChanged": "", |
|
|
|
# "AreaName": "Mahindra", |
|
|
|
# "Zone": "Mahindra", |
|
|
|
# "LocationName": "Mahindra", |
|
|
|
# "ChannelNo": "", |
|
|
|
# "ServerDate": "", |
|
|
|
# "ServerTime": "", |
|
|
|
# "DealerName": "Mahindra", |
|
|
|
# "EmailId": "{}@mahindra.com".format(usr), |
|
|
|
# "isLDAPAuthenticated": ""} |
|
|
|
|
|
|
|
# success_msg = None |
|
|
|
# user_name = None |
|
|
|
# msgDic = {} |
|
|
|
# if len(decoded) > 165: |
|
|
|
# da = re.search("{", decoded) |
|
|
|
# da1 = re.search("}", decoded) |
|
|
|
# trunData = decoded[da.span()[0]:da1.span()[1]] |
|
|
|
# dicData = json.loads(trunData) |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
|
|
|
|
# return dicData |
|
|
|
|
|
|
|
# else: |
|
|
|
# try: |
|
|
|
# msgDic['UserName'] = dictValue['children']['UserName']['text'] |
|
|
|
# msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text'] |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
# return dicData |
|
|
|
# except: |
|
|
|
# return {'status': 0, 'error': 'Invalid Credentials'} |
|
|
|
# else: |
|
|
|
# return {'status': 0, 'error': 'Login Blocked'} |
|
|
|
# except: |
|
|
|
# return {'status': 0, 'error': 'Site Error'} |
|
|
|
# else: |
|
|
|
# try: |
|
|
|
# msgDic['UserName'] = dictValue['children']['UserName']['text'] |
|
|
|
# msgDic['IsSuccessfull'] = dictValue['children']['IsSuccessfull']['text'] |
|
|
|
# doc = frappe.get_doc("Fish", None) |
|
|
|
# dicData['token'] = doc.apple |
|
|
|
# dicData['status'] = 1 |
|
|
|
# if dicData['ID'] == "": |
|
|
|
# dicData['ID'] = "100" |
|
|
|
# return dicData |
|
|
|
# except: |
|
|
|
# return {'status': 0, 'error': 'Invalid Credentials'} |
|
|
|
# else: |
|
|
|
# return {'status': 0, 'error': 'Login Blocked'} |
|
|
|
# except: |
|
|
|
# return {'status': 0, 'error': 'Site Error'} |
|
|
|
|
|
|
|
|
|
|
|
def xml_to_dict(node): |
|
|
|