def insert_update_useraccess(con, cur, insertuseraccess): if insertuseraccess['action'] == 'insert': command = cur.mogrify( """ INSERT INTO unihot.useraccess (userid, logintype, usertype, entityid, entitybranchid, defaultindicator, roleid, site, accessstatus, muserid, octime, lmtime) VALUES (%s,%s,%s, %s,%s,%s, %s, %s, %s, %s, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); """, (insertuseraccess['values']['userid'], insertuseraccess['values']['logintype'], insertuseraccess['values']['usertype'], insertuseraccess['values']['entityid'], insertuseraccess['values']['entitybranchid'], insertuseraccess['values']['defaultindicator'], insertuseraccess['values']['roleid'], insertuseraccess['values']['entitywebsite'], insertuseraccess['values']['accessstatus'], insertuseraccess['values']['userid'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1 elif insertuseraccess['action'] == 'update entity': command = cur.mogrify( """ UPDATE unihot.useraccess SET entityid = %s, lmtime= CURRENT_TIMESTAMP WHERE userid = %s and entityid = 'dummy' """, ( insertuseraccess['values']['entityid'], insertuseraccess['values']['userid'], )) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1 elif insertuseraccess['action'] == 'update entitybranch': command = cur.mogrify( """ UPDATE unihot.useraccess SET entitybranchid = %s, lmtime= CURRENT_TIMESTAMP WHERE userid = %s and entityid = %s and entitybranchid = 'dummy' """, (insertuseraccess['values']['entitybranchid'], insertuseraccess['values']['userid'], insertuseraccess['values']['entityid'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1 else: return cur, 200, 'Action not defined for useraccess'
def get_user_entities(con, cur, getuserentities): command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT entityid AS "entityId", entityname AS "entityName", entityshortname AS "entityShortName", entitycategory AS "entityCategory", entitystatus AS "entityStatus", entitydescription AS "entityDescription", entityimageurl AS "entityImageUrl", entitylogo AS "entityLogo", entityindustry AS "entityIndustry", entitytaxid AS "entityTaxID", entityaddline1 AS "entityAddLine1", entityaddline2 AS "entityAddLine2", entitycity AS "entityCity", entitystate AS "entityState", entitycountry AS "entityCountry", entitypincode AS "entityPinCode", entityphone AS "entityPhone", entityfax AS "entityFax", entitymobile AS "entityMobile", entitywebsite AS "entityWebsite", entityemail AS "entityEmail", entitystartdate AS "entityStartDate", entityfiscalyear AS "entityFiscalYear", entitytimezone AS "entityTimeZone", octime AS "octTime", lmtime AS "lmtTime", muserid AS "muserId" FROM unihot.entity WHERE entityid in (select entityid from unihot.useraccess where userid = %s) and entitystatus = %s ) as a """, (getuserentities['keys']['userid'], getuserentities['keys']['entitystatus'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1
def get_user_entity_branches(con, cur, getuserentitybranches): command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT entityid AS "entityName", entitybranchid AS "entityBranchId", entitybranchname AS "entityBranchName", entitybranchshortname AS "entityBranchShortName", entitybranchcategory AS "entityBranchCategory", entitybranchstatus AS "entityBranchStatus", entitybranchdescription AS "entityBranchDescription", entitybranchimageurl AS "entityBranchImageUrl", entitybranchaddline1 AS "entityBranchAddLine1", entitybranchaddline2 AS "entityBranchAddLine2", entitybranchcity AS "entityBranchCity", entitybranchstate AS "entityBranchState", entitybranchcountry AS "entityBranchCountry", entitybranchpincode AS "entityBranchPinCode", entitybranchphone AS "entityBranchPhone", entitybranchfax AS "entityBranchFax", entitybranchmobile AS "entityBranchMobile", entitybranchwebsite AS "entityBranchWebsite", entitybranchemail AS "entityBranchEmail", entitybranchstartdate AS "entityBranchStartDate", octime AS "octTime", lmtime AS "lmtTime", muserid AS "muserId" FROM unihot.entity_branch WHERE entitybranchid in (select entitybranchid from unihot.useraccess where userid = %s and entityid =%s ) and entitybranchstatus = %s and entityid = %s ) as a """, (getuserentitybranches['keys']['userid'], getuserentitybranches['keys']['entityid'], getuserentitybranches['keys']['entitybranchstatus'], getuserentitybranches['keys']['entityid'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1
def get_bullion_price(con, cur): command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT * from nawg.ibjia ) as a """) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1
def modify_entity_branch(con, cur, modifyentitybranch): command = cur.mogrify( """ UPDATE unihot.entity_branch SET entityid = %s, entitybranchaddline1 = %s, entitybranchaddline2 = %s, entitybranchcategory = %s, entitybranchcity = %s, entitybranchcountry = %s, entitybranchdescription = %s, entitybranchemail = %s, entitybranchfax = %s, entitybranchimageurl = %s, entitybranchmobile = %s, entitybranchname = %s, entitybranchphone = %s, entitybranchpincode = %s, entitybranchshortname = %s, entitybranchstartdate = %s, entitybranchstate = %s, entitybranchstatus = %s, entitybranchwebsite = %s, lmtime = CURRENT_TIMESTAMP, octime = %s, muserid = %s WHERE entitybranchid = %s RETURNING entitybranchid; """, (modifyentitybranch['values']['entityid'], modifyentitybranch['values']['entitybranchaddline1'], modifyentitybranch['values']['entitybranchaddline2'], modifyentitybranch['values']['entitybranchcategory'], modifyentitybranch['values']['entitybranchcity'], modifyentitybranch['values']['entitybranchcountry'], modifyentitybranch['values']['entitybranchdescription'], modifyentitybranch['values']['entitybranchemail'], modifyentitybranch['values']['entitybranchfax'], modifyentitybranch['values']['entitybranchimageurl'], modifyentitybranch['values']['entitybranchmobile'], modifyentitybranch['values']['entitybranchname'], modifyentitybranch['values']['entitybranchphone'], modifyentitybranch['values']['entitybranchpincode'], modifyentitybranch['values']['entitybranchshortname'], modifyentitybranch['values']['entitybranchstartdate'], modifyentitybranch['values']['entitybranchstate'], modifyentitybranch['values']['entitybranchstatus'], modifyentitybranch['values']['entitybranchwebsite'], modifyentitybranch['values']['octime'], modifyentitybranch['values']['muserid'], modifyentitybranch['values']['entitybranchid'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1
def delete_entity(con, cur, userid, entityid): print(entityid) command = cur.mogrify( """ UPDATE unihot.entity SET entitystatus = %s, lmtime = CURRENT_TIMESTAMP, userid = %s WHERE entityid = %s RETURNING entityid; """, ('D', userid, entityid)) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1
def get_linked_apps_nd_save(linked_apps_input): #Get all the linked apps for a acuid print("inside get_linked_apps function") s = 0 f = None t = None #message to front end lnkd_app_data = None lnk_passtkn = linked_apps_input["pass_tkn"] lnk_pass_exp = datetime.strptime(linked_apps_input["pass_tkn_exp"],'%d%m%Y%H%M%S%f') acusrid = linked_apps_input["acuid"] lnk_app_uid = linked_apps_input["lnk_userid"] entityid = linked_apps_input["entityid"] countryid = linked_apps_input["countryid"] #Get con and cur con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s,f,t) if s <= 0: s1, f1 = db.mydbbegin(con, cur) print(s1,f1) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: command = cur.mogrify(""" UPDATE acusr.linkedapps SET lnk_passtkn = %s, lnk_pass_exp = %s WHERE userid = %s AND lnk_userid = %s AND entityid= %s AND countryid = %s; """,(lnk_passtkn, lnk_pass_exp, acusrid, lnk_app_uid, entityid, countryid,)) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s > 0: s, f, t= errhand.get_status(s, 200, f, "SIGNUP update failed", t, "no") print('Insert or update is successful') if s <= 0: con.commit() #get the linked apps for the acuid #Check for Token expiry of all the apps inside CASE if s <= 0: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT *, CASE WHEN (lnk_pass_exp < CURRENT_TIMESTAMP) THEN 'expired' ELSE 'active' END AS pass_tkn_status FROM acusr.linkedapps WHERE lnkstatus = 'L' AND userid = %s AND entityid = %s AND countryid = %s ) as a """,(linked_apps_input["acuid"],linked_apps_input["entityid"],linked_apps_input["countryid"],)) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "User data fetch failed with DB error", t, "no") print(s,f) if s <= 0: print("rowcount") print(cur.rowcount) print("rowcount") if cur.rowcount > 0: lnkd_app_data = cur.fetchall()[0][0] else: lnkd_app_data = None print(lnkd_app_data) print(s,f) if s <= 0: return s, lnkd_app_data else: return s, lnkd_app_data
def nc_pass_tkn(callback_data): #get pass token from nc s = 0 f = None t = None #message to front end lnkd_app_data = None entityid = callback_data["entityid"] countryid = callback_data["countryid"] headers = {"entityid": entityid, "countryid": countryid} req_payload = { "userauthtkn": callback_data["userauthtkn"], "appid": settings.NCAPPID[settings.LIVE], "appkey":settings.NCAPPKEY[settings.LIVE], "redirecturi":settings.MYREDIRURI[settings.LIVE] } print("###########################") print(req_payload) print(type(req_payload)) print("###########################") #r = requests.post(settings.NCPASSURL[settings.LIVE], headers=headers, data=json.dumps(req_payload)) try: r = requests.post(settings.NCPASSURL[settings.LIVE], headers=headers, data=json.dumps(req_payload)) except requests.exceptions.Timeout: print("timeout exception") s, f, t = errhand.get_status(s, 100, f, "Timeout error in sending request to nc", t, "yes") #pan_data = {"pan_name": None, "kyc_status": None} except requests.exceptions.RequestException as e: print("exception") print(e) s, f, t = errhand.get_status(s, 100, f, "error in sending request to nc", t, "yes") else: print(r.content) nc_usr_data = json.loads(r.content.decode("utf-8") ) print(json.loads(r.content.decode("utf-8"))) print('i see') print(type(nc_usr_data)) nc_usr_data = json.loads(nc_usr_data) print(nc_usr_data) print(type(nc_usr_data)) jwtdecoded = jwt.decode(nc_usr_data.get("ncjwt"), verify=False) print(jwtdecoded) ncuid = jwtdecoded["ncuserid"] nc_pass_tkn_exp = jwtdecoded["exp"] #Get acuserid from ncuserid con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s,f,t) #get acuid from ncuid if s <= 0: command = cur.mogrify(""" SELECT userid FROM acusr.linkedapps WHERE lnkstatus = 'L' AND lnk_userid = %s AND entityid = %s AND countryid = %s """,(ncuid,entityid,countryid,)) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "User data fetch failed with DB error", t, "no") print(s,f) if s <= 0: print("rowcount") print(cur.rowcount) print("rowcount") if cur.rowcount > 0: uid = cur.fetchall()[0][0] print(uid) print(s,f) print("rowcount") #Check for other linked apps linked_apps_input = { "acuid": uid, "entityid": entityid, "countryid": countryid, "pass_tkn_exp" : nc_pass_tkn_exp, "pass_tkn": nc_usr_data.get("ncjwt"), "lnk_userid": ncuid } rec_status, linked_apps_lst = get_linked_apps_nd_save(linked_apps_input) if rec_status > 0: s, f, t = errhand.get_status(s, rec_status, f, "Linked app data fetch failed with error", t, "no") print(s,f) return s, linked_apps_lst
def save_usr_details(sav_usr): print("inside save_usr_details function") s = 0 f = None t = None #message to front end rec_status ="fail" con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s,f,t) #validate user existence if s <= 0: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT userid, username, useremail, logintype FROM acusr.userlogin WHERE userstatus NOT IN ('I') AND ( userid = %s OR useremail = %s ) AND entityid = %s AND countryid = %s ) as a """,(sav_usr["uid"],sav_usr["nc_email"],sav_usr["entityid"],sav_usr["countryid"],)) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "User data fetch failed with DB error", t, "no") print(s,f) if s <= 0: db_json_rec = cur.fetchall()[0][0] print(db_json_rec) reg_status, reg_data = allow_regis_user(db_json_rec, sav_usr) print(reg_status) print(reg_data) if reg_status == "fail": s, f, t= errhand.get_status(s, 101, f, reg_data, t, "yes") print(s,f) if s <= 0: s1, f1 = db.mydbbegin(con, cur) print(s1,f1) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: command = cur.mogrify(""" INSERT INTO acusr.userlogin (userid, username, useremail, logintype, userstatus, userstatlstupdt, octime, lmtime, entityid, countryid) VALUES (%s,%s,%s,'I','A',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,%s,%s); """,(sav_usr["uid"], sav_usr["nc_usrname"], sav_usr["nc_email"],settings.INSTALLDATA[settings.LIVE]["entityid"],settings.INSTALLDATA[settings.LIVE]["countryid"],)) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("end of ") if s > 0: s, f, t= errhand.get_status(s, 200, f, "SIGNUP userlogin insert failed", t, "no") print('userlogin Insert or update completed') if s <= 0: command = cur.mogrify(""" INSERT INTO acusr.linkedapps (userid, lnk_app, lnk_userid, lnk_email, lnkstatus, octime, lmtime, entityid, countryid) VALUES (%s,%s,%s,%s,'L',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,%s,%s); """,(sav_usr["uid"], sav_usr["nc_entity"], sav_usr["nc_usrid"], sav_usr["nc_email"],settings.INSTALLDATA[settings.LIVE]["entityid"],settings.INSTALLDATA[settings.LIVE]["countryid"],)) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s > 0: s, f, t= errhand.get_status(s, 200, f, "SIGNUP linkedapps insert failed", t, "no") print('linked app Insert or update completed') if s <= 0: con.commit() db.mydbcloseall(con,cur) if s<= 0: rec_status = "success" msg = "User data saved successfully" else: rec_status = "fail" tt = errhand.front_end_msg if errhand.front_end_msg != None else "" msg = "User data save failed " + tt return rec_status, msg
def app_appauth(criteria_json): print("inside appauth function") s = 0 f = None t = None #message to front end response = None res_to_send = 'fail' payload1 = criteria_json.get("payload", None) print(criteria_json) print(payload1) print(s) if s <= 0: if criteria_json.get("entityid", None) != None: origin_entityid = criteria_json['entityid'] else: origin_entityid = None s, f, t = errhand.get_status(s, 100, f, "Origin entity id not provided", t, "yes") if criteria_json.get("cntryid", None) != None: origin_cntryid = criteria_json['cntryid'] else: origin_cntryid = None s, f, t = errhand.get_status(s, 100, f, "Origin cntry code is not provided", t, "yes") print('origin', origin_entityid, origin_cntryid) #Use the installed entity and country code for further operatios entityid = config.INSTALLDATA[config.LIVE]["entityid"] cntryid = config.INSTALLDATA[config.LIVE]["countryid"] if payload1 == None: s, f, t = errhand.get_status( s, 100, f, "App data not sent. Please try again", t, "yes") else: if payload1.get("userauthtkn", None) != None: userauthtkn = payload1['userauthtkn'] else: userauthtkn = None s, f, t = errhand.get_status( s, 100, f, "User login success authtkn not provided", t, "yes") if payload1.get("appid", None) != None: appid = payload1['appid'] else: appid = None s, f, t = errhand.get_status(s, 100, f, "app id not provided", t, "yes") if payload1.get("appkey", None) != None: appkey = payload1['appkey'] else: appkey = None s, f, t = errhand.get_status(s, 100, f, "appkey is not provided", t, "yes") if payload1.get("redirecturi", None) != None: redirecturi = payload1['redirecturi'] else: redirecturi = None s, f, t = errhand.get_status(s, 100, f, "redirecturi is not provided", t, "yes") # update or create are the values print(userauthtkn, appid, redirecturi, appkey, entityid, cntryid) if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s, f, t) if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT * FROM ncapp.appdetail WHERE delflg != 'Y' AND expirydate >= CURRENT_DATE AND appid = %s AND appkey = %s AND redirecturi = %s AND entityid = %s AND countryid = %s ) as a """, ( appid, appkey, redirecturi, entityid, cntryid, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "App Name data fetch failed with DB error", t, "no") print(s, f) app_db_rec = None if s <= 0: app_db_rec = cur.fetchall()[0][0] print("get db details") print(app_db_rec) if len(app_db_rec) < 1: s, f, t = errhand.get_status(s, 100, f, "Unable to locate the app id", t, "yes") else: app_db_rec = app_db_rec[0] print("appauth.py line 161 App id identified successfully") print(app_db_rec) print(s, f) appuserid = app_db_rec.get("appuserid", None) ''' if app_db_rec["appusertype"] == "D": useridts = appuserid elif app_db_rec["appusertype"] == "A": useridts = appuserid elif app_db_rec["appusertype"] == "P": useridts = appuserid elif app_db_rec["appusertype"] == "I": useridts = appuserid elif app_db_rec["appusertype"] == "T": useridts = appuserid ''' if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT * FROM ncusr.userauth WHERE tknexpiry >= CURRENT_TIMESTAMP AND userauthtkn = %s AND appid = %s AND entityid = %s AND countryid = %s ) as a """, ( userauthtkn, appid, entityid, cntryid, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "User authtoke fetch failed with DB error", t, "no") print(s, f) usr_db_rec = None if s <= 0: usr_db_rec = cur.fetchall()[0][0] print(usr_db_rec) if len(usr_db_rec) < 1: s, f, t = errhand.get_status( s, 100, f, "Unable to locate the user auth details OR Token expired", t, "yes") else: usr_db_rec = usr_db_rec[0] print("User auth token validated successfully") useridts = usr_db_rec["userid"] #We are ready to generate API pass token print(s, f) i = 0 cur_time = datetime.now().strftime('%Y%m%d%H%M%S') passtknset = False pass_tkn = None while i < 50: r = ''.join( random.choice(string.ascii_letters + string.digits) for x in range(6)) pass_tkn = create_signature("md5", "nirunidhapasstkn" + r, userauthtkn + cur_time, appuserid + appid) command = cur.mogrify( """ SELECT count(1) FROM ncapp.appusrauth WHERE passwordtkn = %s """, (pass_tkn, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "Password token data fetch failed with DB error", t, "no") print(s, f) if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) if db_rec > 0: s, f, t = errhand.get_status( s, 100, f, "Pass token Already exists. Retrying time: " + i, t, "no") i = i + 1 continue else: print("Pass code is unique. Generation task completed") passtknset = True break else: # Some error occured, so no point looping passtknset = False break print(s, f, t) appusrtype = app_db_rec.get("appusertype", None) if appusrtype == None: s, f, t = errhand.get_status(s, 200, f, "app user type is not known", t, "yes") if s <= 0 and passtknset: s1, f1 = db.mydbbegin(con, cur) print(s1, f1) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: passexpiry = get_expiry_time(appusrtype) command = cur.mogrify( """ INSERT into ncapp.appusrauth (userauthtkn,appid,passwordtkn,passwordtknexpiry,entityid,countryid,octime,lmtime) VALUES(%s, %s, %s, %s, %s, %s, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) ON CONFLICT ON CONSTRAINT unq_comb_auauth DO UPDATE SET passwordtkn = %s, passwordtknexpiry = %s, lmtime = CURRENT_TIMESTAMP """, ( userauthtkn, appid, pass_tkn, passexpiry, entityid, cntryid, pass_tkn, passexpiry, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s > 0: s, f, t = errhand.get_status(s, 200, f, "passtoken update failed", t, "no") print('Insert or update is successful') if s <= 0: con.commit() if s <= 0: data_for_jwt = { "exp": passexpiry.strftime('%d%m%Y%H%M%S'), "passtkn": pass_tkn, "ei": entityid, "ci": cntryid, "ncuserid": useridts } natjwt = jwtf.generatejwt(data_for_jwt) if s > 0: res_to_send = 'fail' result_date = [] response = { 'result_data': result_date, 'status': res_to_send, 'status_code': s, 'usrmsg': errhand.error_msg_reporting(s, t) } else: res_to_send = 'success' result_date = natjwt response = { 'result_data': result_date, 'status': res_to_send, 'status_code': 0, 'usrmsg': "pass Token generation successful" } print(res_to_send, response) return (res_to_send, response)
def app_userauth(criteria_json): # Generate a user auth token # input # criteria_json = { # "entityid" : entityid, # "cntryid" : cntryid, # "payload" : payload => {appid,redirecturi,userid,expiremin<tokenexipry in mins>} # } # Output # response = { # 'result_data' : result_data, => succ-> {'authtkn': auth_tkn} : err->[] # 'status': res_to_send, => success/fail # 'status_code': 0, # 'usrmsg': "Token generation successful" <=for success: error msg in case of error # } print("inside userauth function") s = 0 f = None t = None #message to front end response = None res_to_send = 'fail' payload = criteria_json.get("payload", None) print(s) if s <= 0: if criteria_json.get("entityid", None) != None: entityid = criteria_json['entityid'] else: entityid = None s, f, t = errhand.get_status(s, 100, f, "entity id not provided", t, "yes") if criteria_json.get("cntryid", None) != None: cntryid = criteria_json['cntryid'] else: cntryid = None s, f, t = errhand.get_status(s, 100, f, "cntry code is not provided", t, "yes") if payload == None: s, f, t = errhand.get_status( s, 100, f, "App data not sent. Please try again", t, "yes") else: if payload.get("appid", None) != None: appid = payload['appid'] else: appid = None s, f, t = errhand.get_status(s, 100, f, "app id not provided", t, "yes") if payload.get("redirecturi", None) != None: redirecturi = payload['redirecturi'] else: redirecturi = None s, f, t = errhand.get_status(s, 100, f, "redirecturi is not provided", t, "yes") if payload.get("userid", None) != None: userid = payload['userid'] else: userid = None s, f, t = errhand.get_status(s, 100, f, "userid is not provided", t, "yes") expiremin = payload.get("expiremin", None) print(appid, redirecturi, entityid, cntryid, userid) if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s, f, t) if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT * FROM ncapp.appdetail WHERE delflg != 'Y' AND expirydate >= CURRENT_DATE AND approved != 'N' AND appid = %s AND redirecturi = %s AND entityid = %s AND countryid = %s ) as a """, ( appid, redirecturi, entityid, cntryid, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "App Name data fetch failed with DB error", t, "no") print(s, f) app_db_rec = None if s <= 0: app_db_rec = cur.fetchall()[0][0] print(app_db_rec) if app_db_rec != None: print(len(app_db_rec)) if app_db_rec == None or len(app_db_rec) < 1: s, f, t = errhand.get_status(s, 100, f, "Unable to locate the app id", t, "yes") else: app_db_rec = app_db_rec[0] print("auth.py line 319 App id identified successfully") pass print(s, f) #appuserid = app_db_rec.get("appuserid", None) if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT * FROM ncusr.userlogin WHERE userid = %s AND entityid = %s AND countryid = %s ) as a """, ( userid, entityid, cntryid, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "User fetch failed with DB error", t, "no") print(s, f) usr_db_rec = None if s <= 0: usr_db_rec = cur.fetchall()[0][0] print(usr_db_rec) if usr_db_rec == None or len(usr_db_rec) < 1: s, f, t = errhand.get_status(s, 100, f, "Unable to locate the user details", t, "yes") else: usr_db_rec = usr_db_rec[0] print("User details fetch successfull") pass if s <= 0: if usr_db_rec["userstatus"] == 'B': #B-Blocked , I-Deleteduser s, f, t = errhand.get_status(s, 100, f, "User is blocked", t, "yes") elif usr_db_rec["userstatus"] == 'I': #B-Blocked , I-Deleteduser s, f, t = errhand.get_status(s, 100, f, "User is Deleted", t, "yes") #We are ready to generate API pass token print(s, f) if s <= 0: i = 0 cur_time = datetime.now().strftime('%Y%m%d%H%M%S') authtknset = False auth_tkn = None while i < 50: r = ''.join( random.choice(string.ascii_letters + string.digits) for x in range(6)) auth_tkn = create_signature("md5", "nirunidhausrtkn" + r, userid + cur_time, appid + cur_time) command = cur.mogrify( """ SELECT count(1) FROM ncusr.userauth WHERE userauthtkn = %s """, (auth_tkn, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "auth token data fetch failed with DB error", t, "no") print(s, f) if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) if db_rec > 0: s, f, t = errhand.get_status( s, 100, f, "auth token Already exists. Retrying time: " + i, t, "no") i = i + 1 continue else: print("Auth token is unique. Generation task completed") authtknset = True break else: # Some error occured, so no point looping authtknset = False break print(s, f, t) appusrtype = None if app_db_rec == None else app_db_rec.get( "appusertype", None) if appusrtype == None: s, f, t = errhand.get_status(s, 200, f, "app user type is not known", t, "yes") if s <= 0 and authtknset: s1, f1 = db.mydbbegin(con, cur) print(s1, f1) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: passexpiry = get_expiry_time("authtkn", appusrtype, expiremin) # VALUES(%s, %s, %s, %(timestamp)s, %s, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) command = cur.mogrify( """ INSERT into ncusr.userauth (userid,appid,userauthtkn,tknexpiry,entityid,countryid,octime,lmtime) VALUES(%s, %s, %s, %s, %s, %s, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) ON CONFLICT ON CONSTRAINT unq_comb_uauth DO UPDATE SET userauthtkn = %s, tknexpiry = %s, lmtime = CURRENT_TIMESTAMP """, ( userid, appid, auth_tkn, passexpiry, entityid, cntryid, auth_tkn, passexpiry, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s > 0: s, f, t = errhand.get_status(s, 200, f, "authtoken update failed", t, "no") print('Insert or update is successful') if s <= 0: con.commit() if s > 0: res_to_send = 'fail' result_data = [] response = { 'result_data': result_data, 'status': res_to_send, 'status_code': s, 'usrmsg': errhand.error_msg_reporting(s, t) } else: res_to_send = 'success' result_data = {'authtkn': auth_tkn} response = { 'result_data': result_data, 'status': res_to_send, 'status_code': 0, 'usrmsg': "Token generation successful" } print(res_to_send, response) return (res_to_send, response)
def ologins(): if request.method == "POST": print("0login1") attempted_username = request.get_json(force=True)['username'] attempted_password = request.get_json(force=True)['password'] # attempted_username = '******' # attempted_password = '******' print(attempted_username, attempted_password) s = 0 f = None t = None # message to front end # attempted_username = '******' # attempted_password = '******' branchid = "test" hotelid = "test" print(attempted_username, attempted_password) print("here") if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s, f, t) if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT userid,username FROM unihot.userlogin WHERE userstatus = 'A' AND uName = %s AND uPassword = %s AND branchid = %s AND hotelid = %s ) as a """, ( attempted_username, attempted_password, branchid, hotelid, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "App Name data fetch failed with DB error", t, "no") print(s, f) db_rec = None if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) print(len(db_rec)) print(db_rec[0]) if db_rec == None or len(db_rec) > 1: s, f, t = errhand.get_status(s, 100, f, "User authentication failed", t, "yes") else: db_rec = db_rec[0] print("auth.py line 136 user auth successfully") pass print(s, f, t) print(db_rec) if s <= 0: redata = [{"uId": db_rec['uid'], "uName": db_rec['uname']}] res = make_response(jsonify(redata), 200) return res else: return jsonify(False)
def insert_entity(con, cur, insertentitybranch): command = cur.mogrify( """ INSERT INTO unihot.entity ( entityaddline1, entityaddline2, entitycategory, entitycity, entitycountry, entitydescription, entityemail, entityfax, entityfiscalyear, entityimageurl, entityindustry, entitylogo, entitymobile, entityname, entityphone, entitypincode, entityshortname, entitystartdate, entitystate, entitystatus, entitytaxid, entitytimezone, entitywebsite, lmtime, octime, muserid ) VALUES (%s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s, CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,%s ) RETURNING entityid; """, (insertentitybranch['values']['entityaddline1'], insertentitybranch['values']['entityaddline2'], insertentitybranch['values']['entitycategory'], insertentitybranch['values']['entitycity'], insertentitybranch['values']['entitycountry'], insertentitybranch['values']['entitydescription'], insertentitybranch['values']['entityemail'], insertentitybranch['values']['entityfax'], insertentitybranch['values']['entityfiscalyear'], insertentitybranch['values']['entityimageurl'], insertentitybranch['values']['entityindustry'], insertentitybranch['values']['entitylogo'], insertentitybranch['values']['entitymobile'], insertentitybranch['values']['entityname'], insertentitybranch['values']['entityphone'], insertentitybranch['values']['entitypincode'], insertentitybranch['values']['entityshortname'], insertentitybranch['values']['entitystartdate'], insertentitybranch['values']['entitystate'], insertentitybranch['values']['entitystatus'], insertentitybranch['values']['entitytaxid'], insertentitybranch['values']['entitytimezone'], insertentitybranch['values']['entitywebsite'], insertentitybranch['values']['muserid'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1
def insert_entity_branch(con, cur, insertentitybranch): command = cur.mogrify( """ INSERT INTO unihot.entity_branch ( entityid, entitybranchaddline1, entitybranchaddline2, entitybranchcategory, entitybranchcity, entitybranchcountry, entitybranchdescription, entitybranchemail, entitybranchfax, entitybranchimageurl, entitybranchmobile, entitybranchname, entitybranchphone, entitybranchpincode, entitybranchshortname, entitybranchstartdate, entitybranchstate, entitybranchstatus, entitybranchwebsite, lmtime, octime, muserid ) VALUES (%s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s,%s, %s,%s,%s, %s, CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,%s ) RETURNING entitybranchid; """, (insertentitybranch['values']['entityid'], insertentitybranch['values']['entitybranchaddline1'], insertentitybranch['values']['entitybranchaddline2'], insertentitybranch['values']['entitybranchcategory'], insertentitybranch['values']['entitybranchcity'], insertentitybranch['values']['entitybranchcountry'], insertentitybranch['values']['entitybranchdescription'], insertentitybranch['values']['entitybranchemail'], insertentitybranch['values']['entitybranchfax'], insertentitybranch['values']['entitybranchimageurl'], insertentitybranch['values']['entitybranchmobile'], insertentitybranch['values']['entitybranchname'], insertentitybranch['values']['entitybranchphone'], insertentitybranch['values']['entitybranchpincode'], insertentitybranch['values']['entitybranchshortname'], insertentitybranch['values']['entitybranchstartdate'], insertentitybranch['values']['entitybranchstate'], insertentitybranch['values']['entitybranchstatus'], insertentitybranch['values']['entitybranchwebsite'], insertentitybranch['values']['muserid'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1
def login(): if request.method == "POST": print("osignup") attempted_username = request.get_json(force=True)['username'] attempted_password = request.get_json(force=True)['password'] s = 0 f = None t = None # message to front end # attempted_username = '******' # attempted_password = '******' branchid = "test" hotelid = "test" print(attempted_username, attempted_password) print("here") if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s, f, t) if s <= 0: command = cur.mogrify( """ INSERT INTO ncusr.userlogin (userid, username, useremail, userstatus, userstatlstupdt, octime, lmtime, entityid, countryid) VALUES (%s,%s,%s,%s,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,%s,%s); """, ( userid, name, sinupemail, userstatus, entityid, countryid, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "App Name data fetch failed with DB error", t, "no") print(s, f) db_rec = None if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) print(len(db_rec)) print(db_rec[0]) if db_rec == None or len(db_rec) > 1: s, f, t = errhand.get_status(s, 100, f, "User authentication failed", t, "yes") else: db_rec = db_rec[0] print("auth.py line 136 user auth successfully") pass print(s, f, t) print(db_rec) if s <= 0: redata = [{"uId": db_rec['uid'], "uName": db_rec['uname']}] res = make_response(jsonify(redata), 200) return res else: return jsonify(False)
def generatejwt(d): #Create JWT print("inside jwt creation function") s = 0 f = None t = None #message to front end response = None res_to_send = 'fail' print(d) con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s, f, t) natseckey = "secret" if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT secretcode,seccdid FROM ncapp.secrettkn WHERE entityid = %s AND countryid =%s ) as a """, (d["ei"], d["ci"])) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "secret fetch failed with DB error", t, "no") print(s, f) db_rec = None if s <= 0: db_rec = cur.fetchall()[0][0] if len(db_rec) < 1: s, f, t = errhand.get_status(s, 100, f, "Unable to get secret", t, "no") else: print(db_rec) db_rec = db_rec[0] print("got the secret string successfully") pass print(s, f) if s <= 0: secretcode = db_rec.get("secretcode", None) if secretcode == None: s, f, t = errhand.get_status(s, 200, f, "unable to get secret code", t, "no") seccdid = db_rec.get("seccdid", None) if seccdid == None: s, f, t = errhand.get_status(s, 200, f, "unable to get secret code id", t, "no") print("@@@@@@@@@@@@@") print(secretcode) print("@@@@@@@@@@@@@") if s <= 0: #Call JWT to generate JWT START natjwt = jwt.encode( { "iss": "ncj", "exp": d["exp"], "iat": datetime.now().strftime('%d%m%Y%H%M%S%f'), "passtkn": d["passtkn"], "skd": seccdid, "eid": d["ei"], "cid": d["ci"], "ncuserid": d["ncuserid"] }, secretcode, algorithm='HS256') print("printing nat jwt") print(natjwt) #Call JWT to generate JWT END db.mydbcloseall(con, cur) return (json.dumps({"ncjwt": natjwt.decode("utf-8")}))
def app_detail_fetch(criteria_json): # payload = {'appid': xyz, 'login': <[noauth] to get data without user id>} # entity id and country id will come in header which are mandator. user id comes in jwt # Output = { 'result_data' : [success -> ncapp.appdetail] [Failure -> ""] # 'status': success/fail, 'status_code': 0, 'usrmsg': ''/error message } print("inside app_detail_fetch common function") s = 0 f = None t = None #message to front end payload = criteria_json.get("payload",None) print(payload) if s <= 0: if payload == None: appid = None login = None # s, f, t= errhand.get_status(s, 100, f, "no payload provided", t, "yes") else: if payload.get("appid", None) != None: appid = payload['appid'] else: appid = None if payload.get("login", None) != None: login = payload['login'] else: login = None print(appid, login, s) if s <= 0: if criteria_json.get("entityid", None) != None: entityid = criteria_json['entityid'] else: entityid = None s, f, t= errhand.get_status(s, 100, f, "entity id not provided", t, "yes") if criteria_json.get("cntryid", None) != None: cntryid = criteria_json['cntryid'] else: cntryid = None s, f, t= errhand.get_status(s, 100, f, "cntry code is not provided", t, "yes") if login != "nologin": if criteria_json.get("userid", None) != None: userid = criteria_json['userid'] else: # To get app details before login for entity and cntry userid = None s, f, t= errhand.get_status(s, 100, f, "user id not provided", t, "yes") else: userid = None if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: if appid == None: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT *, CASE WHEN expirydate < CURRENT_TIMESTAMP THEN 'EXPIRED' ELSE 'ACTIVE' END AS appexp FROM ncapp.appdetail WHERE appuserid = %s AND entityid = %s AND countryid = %s AND delflg = 'N' ) as a """,(userid,entityid,cntryid,)) elif userid == None: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT *, CASE WHEN expirydate < CURRENT_TIMESTAMP THEN 'EXPIRED' ELSE 'ACTIVE' END AS appexp FROM ncapp.appdetail WHERE appid = %s AND entityid = %s AND countryid = %s AND delflg = 'N' ) as a """,(appid,entityid,cntryid,)) else: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT *, CASE WHEN expirydate < CURRENT_TIMESTAMP THEN 'EXPIRED' ELSE 'ACTIVE' END AS appexp FROM ncapp.appdetail WHERE appuserid = %s AND entityid = %s AND countryid = %s AND appid = %s AND delflg = 'N' ) as a """,(userid,entityid,cntryid,appid,)) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "APP data fetch failed with DB error", t, "no") print(s,f) if s <= 0: db_json_rec = cur.fetchall()[0][0] print(db_json_rec) if s > 0: res_to_send = 'fail' response = { 'result_data' : "", 'status': res_to_send, 'status_code': s, 'usrmsg': errhand.error_msg_reporting(s, t) } else: res_to_send = 'success' response = { 'result_data' : db_json_rec, 'status': res_to_send, 'status_code': 0, 'usrmsg': '' } print(res_to_send, response) return (res_to_send, response)
def login(): if request.method == "POST": print("osignup") attempted_username = request.get_json(force=True)['username'] attempted_password = request.get_json(force=True)['password'] s = 0 f = [] # logs for tech guys t = None # message to front end f1 = None # attempted_username = '******' # attempted_password = '******' branchid = "test" hotelid = "test" print(attempted_username, attempted_password) print("here") # if s <= 0: # con, cur, s1, f1 = db.mydbopncon() # s, f, t = errhand.get_status(s, s1, f, f1, t, "no") # s1, f1 = 0, None # print("DB connection established", s, f, t) if s <= 0: con, cur, s, f1 = db.mydbopncon() if s <= 0: if s < 0: f.append(f1) print("DB connection established", s, f, t) else: print("DB connection not established", s, f, t) f.append(f1) t = errhand.set_t(s) redata = [{"f": f, "t": t}] res = make_response(jsonify(redata), 200) return res f.append('warning 1 : testing') userid = attempted_username name = 'mangu' signupemail = '*****@*****.**' userstatus = 'A' entityid = 'bansss' countryid = '473874' if s <= 0: command = cur.mogrify( """ INSERT INTO unihot.userlogin (userid, username, useremail, userstatus, userstatlstupdt, octime, lmtime,logintype, usertype) VALUES (%s,%s,%s,%s,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP, %s, %s); """, ( userid, name, signupemail, userstatus, 'S', 'A', )) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) if s <= 0: if s < 0: f.append(f1) # con.commit() print('Insert or update is successful') command = cur.mogrify( """ INSERT INTO unihot.useraccess (userid, logintype, usertype, entity, entitybranch, defaultindicator, roleid,site, accessstatus, octime, lmtime) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s, CURRENT_TIMESTAMP,CURRENT_TIMESTAMP); """, ( userid, 'dv', 'xx', 'dummy', 'dummy', 'A', 'Admin', 'somesite', 'f', )) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) if s <= 0: if s < 0: f.append(f1) con.commit() print('Insert or update is successful to useraccess') else: f.append(f1) t = errhand.set_t(s) redata = [{"f": f, "t": t}] res = make_response(jsonify(redata), 200) return res else: f.append(f1) t = errhand.set_t(s) redata = [{"f": f, "t": t}] res = make_response(jsonify(redata), 200) return res f.append('warning 1 : testing') print('here 2 s,f,t', s, f, t) print(cur) if s <= 0: db_rec = {'userid': userid, 'username': name} print(db_rec) print(len(db_rec)) # print(db_rec[0]) if db_rec is None: print('do something over here') else: # db_rec = db_rec[0] print("auth.py line 136 user auth successfully") pass print(s, f, t) print(db_rec) if s <= 0: redata = [{"uId": db_rec['userid'], "uName": db_rec['username']}] res = make_response(jsonify(redata), 200) return res else: return jsonify(False)
def app_register(criteria_json): print("inside login GET") s = 0 f = None t = None #message to front end response = None res_to_send = 'fail' payload = criteria_json.get("payload",None) print(s) if s <= 0: if criteria_json.get("userid", None) != None: userid = criteria_json['userid'] else: userid = None s, f, t= errhand.get_status(s, 100, f, "user id not provided", t, "yes") if criteria_json.get("entityid", None) != None: entityid = criteria_json['entityid'] else: entityid = None s, f, t= errhand.get_status(s, 100, f, "entity id not provided", t, "yes") if criteria_json.get("cntryid", None) != None: cntryid = criteria_json['cntryid'] else: cntryid = None s, f, t= errhand.get_status(s, 100, f, "cntry code is not provided", t, "yes") if payload == None: s, f, t= errhand.get_status(s, 100, f, "App data not sent. Please try again", t, "yes") else: if payload.get("appname", None) != None: appname = payload['appname'] else: appname = None s, f, t= errhand.get_status(s, 100, f, "No App name provided", t, "yes") if payload.get("appusertype", None) != None: appusertype = payload['appusertype'] else: appusertype = None s, f, t= errhand.get_status(s, 100, f, "App user type not provided", t, "yes") if payload.get("redirecturi", None) != None: redirecturi = payload['redirecturi'] else: redirecturi = None s, f, t= errhand.get_status(s, 100, f, "Redirect URI not provided", t, "yes") if payload.get("postbackuri", None) != None: postbackuri = payload['postbackuri'] else: postbackuri = None s, f, t= errhand.get_status(s, 0, f, "postbackuri not provided", t, "no") if payload.get("description", None) != None: description = payload['description'] else: description = None s, f, t= errhand.get_status(s, -100, f, "description not provided", t, "no") if payload.get("starmfdet", None) != None: starmfdet = payload['starmfdet'] else: starmfdet = None if appusertype not in ['D','A']: s, f, t= errhand.get_status(s, -100, f, "star mf data not provided", t, "yes") else: s, f, t= errhand.get_status(s, -100, f, "star mf data not provided", t, "no") if payload.get("product", None) != None: product = payload['product'] else: product = None s, f, t= errhand.get_status(s, -100, f, "product not provided", t, "no") if payload.get("operation", None) != None: operation = payload['operation'] else: operation = None s, f, t= errhand.get_status(s, -100, f, "operation not provided", t, "no") # update or create are the values if operation == "delete" or operation == "update": if payload.get("appid", None) != None: appid = payload['appid'] else: appid = None s, f, t= errhand.get_status(s, -100, f, "appid not provided", t, "no") if payload.get("appkey", None) != None: appkey = payload['appkey'] else: appkey = None s, f, t= errhand.get_status(s, -100, f, "appkey not provided", t, "no") else: appid = None appkey = None if appusertype == 'T': approved = 'N' else: approved = 'Y' print(appid,"oiipoi", appkey) cur_time = datetime.now().strftime('%Y%m%d%H%M%S') print(appname,appusertype,redirecturi,postbackuri,description,starmfdet) if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("connection statment done", s,f,t) if s <= 0: command = cur.mogrify(""" SELECT count(1) FROM ncapp.appdetail a WHERE delflg != 'Y' AND ( appname = %s ) AND appuserid = %s AND entityid = %s AND countryid = %s """,(appname, userid, entityid, cntryid,) ) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "App Name data fetch failed with DB error", t, "no") print(s,f) if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) if db_rec > 0: if operation == "create": s, f, t= errhand.get_status(s, 100, f, "App name Already exists for this user", t, "yes") else: if operation == "update" or operation == "delete": s, f, t= errhand.get_status(s, 100, f, "App name doesn't exists for this user", t, "yes") print("no records satifying the current user inputs") print(s,f) appikset = False i = 0 if s <= 0 and operation == "create": while i < 50: r = ''.join(random.choice(string.ascii_letters + string.digits) for x in range(6)) appid = create_signature("sha256", "nirunidhaappid" + r, userid + cur_time, userid) appkey = create_signature("md5", "nirunidhaappkey" + r, userid + cur_time, userid) command = cur.mogrify(""" SELECT count(1) FROM ncapp.appdetail WHERE delflg != 'Y' AND ( appid = %s OR appkey = %s ) """,(appid, appkey,) ) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "App Name data fetch failed with DB error", t, "no") print(s,f) if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) if db_rec > 0: s, f, t= errhand.get_status(s, 100, f, "Appid or key Already exists for retrying time: " + i, t, "no") i = i + 1 continue else: print("no records satifying the current user inputs") appikset = True break else: # Some error occured, so no point looping appikset = False break print(s,f, t) if s <= 0 and operation == "create" and appikset: s1, f1 = db.mydbbegin(con, cur) print(s1,f1) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: command = cur.mogrify(""" INSERT INTO ncapp.appdetail (appname, appusertype, redirecturi, postbackuri, description, starmfdet, appid, appkey, expirydate, approved, product, delflg, appuserid, octime, lmtime, entityid, countryid) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,CURRENT_DATE + INTERVAL'1 month', %s, %s, 'N',%s,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,%s,%s); """,(appname, appusertype, redirecturi, postbackuri, description, starmfdet, appid, appkey, approved, product, userid, entityid, cntryid,)) print(command) print(appname,appusertype,redirecturi,postbackuri,description,starmfdet,userid) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s > 0: s, f, t= errhand.get_status(s, 200, f, "SIGNUP update failed", t, "no") print('Insert or update is successful') if s <= 0: con.commit() #validate PAN adn store PAN number if s <= 0 and operation == "update": s1, f1 = db.mydbbegin(con, cur) print(s1,f1) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: command = cur.mogrify(""" UPDATE ncapp.appdetail SET redirecturi = %s, postbackuri = %s, description = %s, starmfdet = %s, lmtime = CURRENT_TIMESTAMP WHERE appname = %s AND appusertype = %s AND appid =%s AND appkey = %s AND product = %s AND appuserid = %s AND entityid = %s AND countryid = %s; """,(redirecturi, postbackuri, description, starmfdet, appname, appusertype, appid, appkey, product, userid, entityid, cntryid,)) print(command) print(appname,appusertype,redirecturi,postbackuri,description,starmfdet,userid) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s > 0: s, f, t= errhand.get_status(s, 200, f, "APP details update failed", t, "no") print('Insert or update is successful') if s <= 0: con.commit() print("commit done") #validate PAN adn store PAN number if s <= 0 and operation == "delete": s1, f1 = db.mydbbegin(con, cur) print(s1,f1) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s <= 0: command = cur.mogrify(""" UPDATE ncapp.appdetail SET delflg = 'Y', lmtime = CURRENT_TIMESTAMP WHERE appname = %s AND appusertype = %s AND appid =%s AND appkey = %s AND product = %s AND appuserid = %s AND entityid = %s AND countryid = %s; """,(appname, appusertype, appid, appkey, product, userid, entityid, cntryid,)) print(command) print(appname,appusertype,redirecturi,postbackuri,description,starmfdet,userid) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t= errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None if s > 0: s, f, t= errhand.get_status(s, 200, f, "APP details update failed", t, "no") print('Insert or update is successful') if s <= 0: con.commit() #validate PAN adn store PAN number usrmg_fstr = None if s > 0: res_to_send = 'fail' result_date = [] response = { 'result_data' : result_date, 'status': res_to_send, 'status_code': s, 'usrmsg': errhand.error_msg_reporting(s, t) } else: res_to_send = 'success' result_date = [{'appname': appname, 'appid': appid}] print("**********************") print(operation) print("**********************") if operation == "create": usrmg_fstr = ") creation is successful" elif operation == "update": usrmg_fstr = ") updation is successful" elif operation == "delete": usrmg_fstr = ") deletion is successful" response = { 'result_data' : result_date, 'status': res_to_send, 'status_code': 0, 'usrmsg': 'App (' + appname + usrmg_fstr } print(res_to_send, response) return (res_to_send, response)
def fn_appname(criteria_json): print("inside fn_appname function") s = 0 f = None t = None #message to front end response = None res_to_send = 'fail' payload = criteria_json.get("payload", None) print(s) if s <= 0: if criteria_json.get("entityid", None) != None: entityid = criteria_json['entityid'] else: entityid = None s, f, t = errhand.get_status(s, 100, f, "entity id not provided", t, "yes") if criteria_json.get("cntryid", None) != None: cntryid = criteria_json['cntryid'] else: cntryid = None s, f, t = errhand.get_status(s, 100, f, "cntry code is not provided", t, "yes") if payload == None: s, f, t = errhand.get_status( s, 100, f, "App data not sent. Please try again", t, "yes") else: if payload.get("appid", None) != None: appid = payload['appid'] else: appid = None s, f, t = errhand.get_status(s, 100, f, "app id not provided", t, "yes") if payload.get("redirecturi", None) != None: redirecturi = payload['redirecturi'] else: redirecturi = None s, f, t = errhand.get_status(s, 100, f, "redirecturi is not provided", t, "yes") # update or create are the values print(appid, redirecturi, entityid, cntryid) if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s, f, t) if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT * FROM ncapp.appdetail WHERE delflg != 'Y' AND expirydate >= CURRENT_DATE AND approved != 'N' AND appid = %s AND redirecturi = %s AND entityid = %s AND countryid = %s ) as a """, ( appid, redirecturi, entityid, cntryid, )) print(command) cur, s1, f1 = db.mydbfunc(con, cur, command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status( s, 200, f, "App Name data fetch failed with DB error", t, "no") print(s, f) db_rec = None if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) if db_rec == None or len(db_rec) > 1: s, f, t = errhand.get_status(s, 100, f, "Unable to locate the app id", t, "yes") else: db_rec = db_rec[0] print("auth.py line 136 App id identified successfully") pass print(s, f) if s > 0: res_to_send = 'fail' result_date = [] response = { 'result_data': result_date, 'status': res_to_send, 'status_code': s, 'usrmsg': errhand.error_msg_reporting(s, t) } else: res_to_send = 'success' result_data = {"appname": db_rec["appname"]} response = { 'result_data': result_data, 'status': res_to_send, 'status_code': 0, 'usrmsg': "Token generation successful" } print(res_to_send, response) return (res_to_send, response)
def fetch_app_data_only_wth_tkn(criteria_json): # Description : Fetch app data # Functional use : # Called from : appfuncs.py->ncappfetchfrmtkn # Request data <criteria_json>: # criteria_json = {"entityid": entityid, "countryid": countryid, "payload": <as per below>} # payload = {"userauthtkn": callback_data["regdata"], "appid": settings.NCAPPID,"appkey":settings.NCAPPKEY} # Response from this endpoint: # Field Name success fail # ----------------------------------------------------------- # { # "userauthtkn": new_userauthtkn, BLANK # "tknexpiry": usr_db_rec["tknexpiry"], BLANK # "userid": more_usr_db_rec["userid"], BLANK # "username": more_usr_db_rec["username"], BLANK # "emailid": more_usr_db_rec["sinupemail"], BLANK # "status": success fail # "msg": BLANK fail message # } # called functions: None print("inside fetch_app_data_only_wth_tkn function") s = 0 f = None t = None #message to front end print(criteria_json) payload = criteria_json.get("payload",None) print(payload) if payload == None: appid = None appkey = None userauthtkn = None # s, f, t= errhand.get_status(s, 100, f, "no payload provided", t, "yes") else: if payload.get("appid", None) != None: appid = payload['appid'] else: appid = None s, f, t= errhand.get_status(s, 100, f, "appid not provided", t, "yes") if payload.get("appkey", None) != None: appkey = payload['appkey'] else: appkey = None s, f, t= errhand.get_status(s, 100, f, "appkey not provided", t, "yes") if payload.get("userauthtkn", None) != None: userauthtkn = payload['userauthtkn'] else: userauthtkn = None s, f, t= errhand.get_status(s, 100, f, "usertoken is not provided", t, "yes") print(appid, appkey, userauthtkn) if s <= 0: con, cur, s1, f1 = db.mydbopncon() s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print("DB connection established", s,f,t) if s <= 0: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT * FROM ncusr.userauth WHERE tknexpiry >= current_timestamp AND appid = %s AND userauthtkn = %s AND entityid = %s AND countryid = %s ) as a """,(appid, userauthtkn, config.INSTALLDATA[config.LIVE]["entityid"],config.INSTALLDATA[config.LIVE]["countryid"],) ) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "User auth token data fetch failed with DB error", t, "no") print(s,f) usr_db_rec = None if s <= 0: usr_db_rec = cur.fetchall()[0][0] print(usr_db_rec) if usr_db_rec != None: print(len(usr_db_rec)) if usr_db_rec == None or len(usr_db_rec) < 1: s, f, t= errhand.get_status(s, 100, f, "User auth token is not valid", t, "yes") else: usr_db_rec = usr_db_rec[0] print("Userauth token verified successfully") pass print(s,f) if s <= 0: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT * FROM ncapp.appdetail WHERE appid = %s AND appkey = %s AND entityid = %s AND countryid = %s AND delflg != 'Y' ) as a """,(appid, appkey, config.INSTALLDATA[config.LIVE]["entityid"],config.INSTALLDATA[config.LIVE]["countryid"],) ) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "User auth token data fetch failed with DB error", t, "no") print(s,f) app_db_rec = None if s <= 0: app_db_rec = cur.fetchall()[0][0] print(app_db_rec) if app_db_rec != None: print(len(app_db_rec)) if app_db_rec == None or len(app_db_rec) < 1: s, f, t= errhand.get_status(s, 100, f, "App id is not valid", t, "yes") else: app_db_rec = app_db_rec[0] if app_db_rec["approved"] == 'N': s, f, t= errhand.get_status(s, 100, f, "App id not approved yet", t, "yes") else: print("App id verified successfully") print(s,f) if s <= 0: command = cur.mogrify(""" SELECT json_agg(a) FROM ( SELECT * FROM ncusr.userdetails a, ncusr.userlogin b WHERE a.userid = %s AND a.entityid = %s AND a.countryid = %s AND a.userid = b.userid AND a.entityid = b.entityid AND a.countryid = b.countryid ) as a """,(usr_db_rec["userid"], config.INSTALLDATA[config.LIVE]["entityid"],config.INSTALLDATA[config.LIVE]["countryid"],) ) print(command) cur, s1, f1 = db.mydbfunc(con,cur,command) s, f, t = errhand.get_status(s, s1, f, f1, t, "no") s1, f1 = 0, None print('----------------') print(s) print(f) print('----------------') if s > 0: s, f, t = errhand.get_status(s, 200, f, "User details data fetch failed with DB error", t, "no") print(s,f) more_usr_db_rec = None if s <= 0: more_usr_db_rec = cur.fetchall()[0][0] print(more_usr_db_rec) print(len(more_usr_db_rec)) if more_usr_db_rec == None or len(more_usr_db_rec) < 1: s, f, t= errhand.get_status(s, 100, f, "User details not available for the given auth token", t, "yes") else: more_usr_db_rec = more_usr_db_rec[0] print("user details fetched successfully") pass print(s,f) if s <= 0: #Validate the user status if more_usr_db_rec["userstatus"] == 'B': #B-Blocked , I-Deleteduser s, f, t= errhand.get_status(s, 100, f, "User is blocked", t, "yes") elif more_usr_db_rec["userstatus"] == 'I': #B-Blocked , I-Deleteduser s, f, t= errhand.get_status(s, 100, f, "User is Deleted", t, "yes") if s <= 0: data_to_auth_tkn = { "entityid": config.INSTALLDATA[config.LIVE]["entityid"], "cntryid" : config.INSTALLDATA[config.LIVE]["countryid"], "payload" : { "appid" : app_db_rec["appid"], "redirecturi" : app_db_rec["redirecturi"], "userid" : more_usr_db_rec["userid"] } } ath_tkn_status, ath_tkn_detail = myauth.app_userauth(data_to_auth_tkn) print("new ath_tkn_detail") print(ath_tkn_detail) if ath_tkn_status == "success": s, f, t= errhand.get_status(s, 0, f, "User auth token regenerated", t, "no") new_userauthtkn = ath_tkn_detail["result_data"]["authtkn"] print(new_userauthtkn) else: s, f, t= errhand.get_status(s, 100, f, "error in User auth token regeneration", t, "no") new_userauthtkn = None res_status = None if s <= 0: res_status = "success" user_auth_detais = { "userauthtkn": new_userauthtkn, "tknexpiry": usr_db_rec["tknexpiry"], "userid": more_usr_db_rec["userid"], "username": more_usr_db_rec["username"], "emailid": more_usr_db_rec["sinupemail"], "status": res_status, "msg":"" } else: res_status = "fail" user_auth_detais = { "userauthtkn": "", "userid": "", "username": "", "emailid": "", "status": res_status, "msg": t } print("rached end") return res_status, user_auth_detais
def login(): if request.method == "GET": print("oentity") attempted_entityname = request.get_json(force=True)['entityName'] s = 0 f = [] # logs for tech guys t = None # message to front end f1 = None # attempted_username = '******' # attempted_password = '******' branchid = "test" hotelid = "test" print(attempted_entityname) print("here") # if s <= 0: # con, cur, s1, f1 = db.mydbopncon() # s, f, t = errhand.get_status(s, s1, f, f1, t, "no") # s1, f1 = 0, None # print("DB connection established", s, f, t) if s <= 0: con, cur, s, f1 = db.mydbopncon() if s <= 0: if s < 0: f.append(f1) print("DB connection established", s, f, t) else: print("DB connection not established", s, f, t) f.append(f1) t = errhand.set_t(s) redata = [{"f": f, "t": t}] res = make_response(jsonify(redata), 200) return res f.append('warning 1 : testing') aentityname = attempted_entityname name = 'mangu' signupemail = '*****@*****.**' userstatus = 'A' entityid = 'bansss' countryid = '473874' entitystatus = 'A' if s <= 0: command = cur.mogrify( """ SELECT json_agg(a) FROM ( SELECT entityid,entityname FROM unihot.ownentity WHERE entitystatus = %s AND entityname = %s ) as a """, ( entitystatus, attempted_entityname, )) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) if s <= 0: if s < 0: f.append(f1) print('fetch is successful') else: f.append(f1) t = errhand.set_t(s) redata = [{"f": f, "t": t}] res = make_response(jsonify(redata), 200) return res f.append('warning 1 : testing') print('here 2 s,f,t', s, f, t) print(cur) db_rec = None if s <= 0: db_rec = cur.fetchall()[0][0] print(db_rec) # print(db_rec[0]) if db_rec is None: print('do something over here') t = 'data couldnt be extracted from fetch results' redata = [{"t": t}] res = make_response(jsonify(redata), 200) return res else: # db_rec = db_rec[0] print("fetch results extracted") pass print(s, f, t) print(db_rec) if s <= 0: # redata = [{"uId": db_rec['userid'], "uName": db_rec['username']}] redata = db_rec res = make_response(jsonify(redata), 200) return res else: return jsonify(False) elif request.method == "POST": print("oentity") attempted_username = request.get_json(force=True)['username'] attempted_password = request.get_json(force=True)['password'] s = 0 f = [] # logs for tech guys t = None # message to front end f1 = None # attempted_username = '******' # attempted_password = '******' branchid = "test" hotelid = "test" print(attempted_username, attempted_password) print("here") # if s <= 0: # con, cur, s1, f1 = db.mydbopncon() # s, f, t = errhand.get_status(s, s1, f, f1, t, "no") # s1, f1 = 0, None # print("DB connection established", s, f, t) if s <= 0: con, cur, s, f1 = db.mydbopncon() if s <= 0: if s < 0: f.append(f1) print("DB connection established", s, f, t) else: print("DB connection not established", s, f, t) f.append(f1) t = errhand.set_t(s) redata = [{"f": f, "t": t}] res = make_response(jsonify(redata), 200) return res f.append('warning 1 : testing') userid = attempted_username name = 'mangu' signupemail = '*****@*****.**' userstatus = 'A' entityid = 'bansss' countryid = '473874' if s <= 0: command = cur.mogrify( """ INSERT INTO unihot.ownentity (userid, username, useremail, userstatus, userstatlstupdt, octime, lmtime,logintype, usertype) VALUES (%s,%s,%s,%s,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP, %s, %s); """, ( userid, name, signupemail, userstatus, 'S', 'A', )) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) if s <= 0: if s < 0: f.append(f1) con.commit() print('Insert or update is successful') else: f.append(f1) t = errhand.set_t(s) redata = [{"f": f, "t": t}] res = make_response(jsonify(redata), 200) return res f.append('warning 1 : testing') print('here 2 s,f,t', s, f, t) print(cur) if s <= 0: db_rec = {'userid': userid, 'username': name} print(db_rec) print(len(db_rec)) # print(db_rec[0]) if db_rec is None: print('do something over here') else: # db_rec = db_rec[0] print("auth.py line 136 user auth successfully") pass print(s, f, t) print(db_rec) if s <= 0: redata = [{"uId": db_rec['userid'], "uName": db_rec['username']}] res = make_response(jsonify(redata), 200) return res else: return jsonify(False)
def modify_entity(con, cur, modifyentitybranch): command = cur.mogrify( """ UPDATE unihot.entity SET entityaddline1 = %s, entityaddline2 = %s, entitycategory = %s, entitycity = %s, entitycountry = %s, entitydescription = %s, entityemail = %s, entityfax = %s, entityfiscalyear = %s, entityimageurl = %s, entityindustry = %s, entitylogo = %s, entitymobile = %s, entityname = %s, entityphone = %s, entitypincode = %s, entityshortname = %s, entitystartdate = %s, entitystate = %s, entitystatus = %s, entitytaxid = %s, entitytimezone = %s, entitywebsite = %s, lmtime = CURRENT_TIMESTAMP, octime = %s, muserid = %s WHERE entityid = %s RETURNING entityid; """, (modifyentitybranch['values']['entityaddline1'], modifyentitybranch['values']['entityaddline2'], modifyentitybranch['values']['entitycategory'], modifyentitybranch['values']['entitycity'], modifyentitybranch['values']['entitycountry'], modifyentitybranch['values']['entitydescription'], modifyentitybranch['values']['entityemail'], modifyentitybranch['values']['entityfax'], modifyentitybranch['values']['entityfiscalyear'], modifyentitybranch['values']['entityimageurl'], modifyentitybranch['values']['entityindustry'], modifyentitybranch['values']['entitylogo'], modifyentitybranch['values']['entitymobile'], modifyentitybranch['values']['entityname'], modifyentitybranch['values']['entityphone'], modifyentitybranch['values']['entitypincode'], modifyentitybranch['values']['entityshortname'], modifyentitybranch['values']['entitystartdate'], modifyentitybranch['values']['entitystate'], modifyentitybranch['values']['entitystatus'], modifyentitybranch['values']['entitytaxid'], modifyentitybranch['values']['entitytimezone'], modifyentitybranch['values']['entitywebsite'], modifyentitybranch['values']['octime'], modifyentitybranch['values']['muserid'], modifyentitybranch['values']['entityid'])) print(command) cur, s, f1 = db.mydbfunc(con, cur, command) return cur, s, f1