def forgotpasswordhash(hashvalue): userid = "" token = "" getuserdata = list( User.find( { "$and": [{ "forgotpasswordJSON.forgotpasswordhash": hashvalue }, { "forgotpasswordJSON.forgotpassworduseddatetime": -1 }] }, {"_id": 0})) if len(getuserdata) == 1: for userdata in getuserdata: forgotpassworduseddatetime = datetime.now() User.update( { "userid": userdata['userid'], "forgotpasswordJSON.forgotpasswordhash": hashvalue }, { "$set": { "forgotpasswordJSON.$.forgotpassworduseddatetime": forgotpassworduseddatetime } }) userid = userdata['userid'] token = userdata['token'] return render_template("front_saveonjobs/forgot_password.html", userid=userid, token=token) else: return jsonify({"status": 200, "message": "URL not found."})
def verify_mobile_otp(): userid = int(request.json['userid']) token = request.json['token'] findUser = User.find_one({ "userid": userid, "token": token, "mobile": str(request.json['mobile']), "mobileotp": int(request.json['mobileotp']), "isdcode": int(request.json['isdcode']), "mobileverified": False, "active": True }) if findUser is not None: result = User.update( { "userid": userid, "token": token, "mobile": str(request.json['mobile']) }, {"$set": { "mobileverified": True, "proJSON.mobileverified": True }}) sendText = "Your Mobile Number is registered to SAVEonJOBS." full_mobile_number = "+" + str(request.json['isdcode']) + str( request.json['mobile']) message = msgclient.messages.create(body=sendText, to=full_mobile_number, from_=Constants.MSG_SEND_FROM) print(message.sid) MessageTracks.insert({ "messagetrackid": CommonUtils.generateRandomNo(MessageTracks, "messagetrackid"), "userid": userid, "mobile": full_mobile_number, "messagetext": sendText, "messagesid": message.sid, "createdatetime": datetime.now(), "updatedatetime": datetime.now() }) userdata = list(User.find({"userid": userid}, {"_id": 0})) return jsonify({ 'status': 200, 'message': 'Verify Successfully.', "userdata": userdata }) else: return jsonify({ 'status': 201, 'message': "OTP and Mobile Number doesn't match." })
def userDataResponse(emailhash): #return jsonify({"ok": "k"}) user = list(User.find({"emailhash": emailhash}, {"_id": 0})) response = dict() if len(user) != 0: response.update({'userid': user[0]['userid']}) response.update({'firstname': user[0]['firstname']}) response.update({'lastname': user[0]['lastname']}) response.update({'gender': user[0]['gender']}) #response.update({'addressJSON': user[0]['addressJSON']}) response.update({'registeredfrom': user[0]['registeredfrom']}) response.update({'email': user[0]['email']}) response.update({'picurl': user[0]['picurl']}) response.update({'token': user[0]['token']}) if user[0]['addressJSON']['city'] != '': city = list( db.city.find({"cityid": user[0]['addressJSON']['city']}, {"_id": 0})) response.update({"city": city[0]['city']}) else: response.update({"city": ""}) if user[0]['addressJSON']['state'] != '': state = list( db.state.find({"stateid": user[0]['addressJSON']['state']}, {"_id": 0})) response.update({"state": state[0]['state']}) else: response.update({"state": ""}) if user[0]['addressJSON']['country'] != '': country = list( db.country.find( {"countryid": user[0]['addressJSON']['country']}, {"_id": 0})) response.update({"country": country[0]['country']}) else: response.update({"country": ""}) #return response response.update({'address1': user[0]['addressJSON']['address1']}) response.update({'address2': user[0]['addressJSON']['address2']}) response.update({'pincode': user[0]['addressJSON']['pincode']}) response.update({'registeredfrom': user[0]['registeredfrom']}) response.update({'emailverified': user[0]['emailverified']}) return response else: return response
def register(): try: firstname = request.json['fname'] lastname = request.json['lname'] email = request.json['email'] regtype = int(request.json['regtype']) mobile = request.json['mobile'] cityid = request.json['city'] skill = request.json['skill'] stateid = request.json['state'] countryid = request.json['country'] picurl = request.json['picurl'] gender = request.json['gender'] locationid = request.json['locationid'] if locationid != "": locationid = int(locationid) if picurl == '': picurl = "default-image.jpg" ''' if city!="": citylist=db.city.find_one({"city":city},{"_id":0,"cityid":1}) cityid=citylist['cityid'] else: cityid="" if state!="": statelist=db.state.find_one({"state":state},{"_id":0,"stateid":1}) stateid=statelist['stateid'] else: stateid="" if country!="": countrylist=db.country.find_one({"country":country},{"_id":0,"countryid":1}) countryid=countrylist['countryid'] else: countryid="" ''' addressJSON = { "address1": request.json['address1'], "address2": request.json['address2'], "city": cityid, "state": stateid, "country": countryid, "pincode": request.json['pincode'] } salt = CommonUtils.generateRandomName() emailhash = CommonUtils.getHashValue() token = CommonUtils.generateRandomName() if regtype == 0: password = request.json['password'] password = CommonUtils.password_hash(password, salt) sociallogin = False emailverified = False fbid = "" fbaccesstoken = "" registeredfrom = "jobwork" else: password = "" sociallogin = True emailverified = True fbid = request.json['fbid'] fbaccesstoken = request.json['fbaccesstoken'] if regtype == 1: registeredfrom = "facebook" elif regtype == 2: registeredfrom = "gmail" #return jsonify({"ok":1}) userdata = list(User.find({"email": email}, {"_id": 0})) if User.count({"email": email}) == 0: userid = CommonUtils.generateRandomNo(User, "userid") User.insert({ "userid": userid, "signupJSON": "", "email": email, "emailverified": emailverified, "emailhash": emailhash, "mobile": mobile, "mobileverified": False, "mobileotp": "", "isdcode": None, "fbid": fbid, "fbaccesstoken": fbaccesstoken, "password": password, "salt": salt, "token": token, "firstname": firstname, "lastname": lastname, "isadmin": False, "createddatetime": datetime.now(), "updateddatetime": datetime.now(), "addressJSON": addressJSON, "paymentdetailsJSON": [], "skillsJSON": skill, "languagesJSON": [], "educationCSV": [], "workplaceCSV": [], "certificateJSON": [], "proJSON": [], "forgotpasswordJSON": [], "gender": gender, "dob": "", "locationid": locationid, "aboutme": "", "picurl": picurl, "reportedJSON": [], "notificationJSON": [], "socaillogin": sociallogin, "facebookpicurl": "", "active": True, "paypal_id": "", "registeredfrom": registeredfrom }) if regtype != 0: response = userDataResponse(email) # user = list(User.find({"email": email}, {"_id": 0})) return jsonify({ "status": 200, "response": response, "message": "", "error": False, "registedfrom": registeredfrom }) else: emailhash = CommonUtils.getHashValue() result = User.update( { "userid": userid, "token": token, "email": request.json['email'] }, {"$set": { "emailhash": emailhash }}) # Send email verification reset_password_link = str(URL) + "emailverify/" + str( emailhash) subject = "Your jobwork.io Account Email Verification" msg = Message(subject, sender=("JobWork", "*****@*****.**"), recipients=[email]) msg.html = render_template( '/emailTemplates/email_verification_template.html', name=firstname, resetLink=reset_password_link, email=email) mail.send(msg) EmailTracks.insert({ "emailtrackid": CommonUtils.generateRandomNo(EmailTracks, "emailtrackid"), "userid": userid, "email": request.json['email'], "subject": subject, "emailtext": msg.html, "createdatetime": datetime.now(), "updatedatetime": datetime.now() }) return jsonify({ "status": 200, "response": {}, "message": "verification mail sent", "error": True, "registedfrom": registeredfrom }) elif userdata[0]['emailverified'] == False: emailhash = CommonUtils.getHashValue() userid = CommonUtils.generateRandomNo(User, "userid") db.user.remove({"email": email}) User.insert({ "userid": userid, "signupJSON": "", "email": email, "emailverified": emailverified, "emailhash": emailhash, "mobile": mobile, "mobileverified": False, "mobileotp": "", "isdcode": None, "fbid": fbid, "fbaccesstoken": fbaccesstoken, "password": password, "salt": salt, "token": token, "firstname": firstname, "lastname": lastname, "isadmin": False, "createddatetime": datetime.now(), "updateddatetime": datetime.now(), "addressJSON": addressJSON, "paymentdetailsJSON": [], "skillsJSON": skill, "languagesJSON": [], "educationCSV": [], "workplaceCSV": [], "certificateJSON": [], "proJSON": [], "forgotpasswordJSON": [], "gender": gender, "dob": "", "locationid": locationid, "aboutme": "", "picurl": picurl, "reportedJSON": [], "notificationJSON": [], "socaillogin": sociallogin, "facebookpicurl": "", "active": True, "paypal_id": "", "registeredfrom": registeredfrom }) if regtype != 0: response = userDataResponse(email) return jsonify({ "status": 200, "response": response, "message": "existed now updated", "error": False, "registedfrom": registeredfrom }) else: emailhash = CommonUtils.getHashValue() result = User.update( { "userid": userid, "token": token, "email": request.json['email'] }, {"$set": { "emailhash": emailhash }}) # Send email verification reset_password_link = str(URL) + "emailverify/" + str( emailhash) subject = "Your jobwork.io Account Email Verification" msg = Message(subject, sender=("JobWork", "*****@*****.**"), recipients=[email]) msg.html = render_template( '/emailTemplates/email_verification_template.html', name=firstname, resetLink=reset_password_link, email=email) mail.send(msg) EmailTracks.insert({ "emailtrackid": CommonUtils.generateRandomNo(EmailTracks, "emailtrackid"), "userid": userid, "email": request.json['email'], "subject": subject, "emailtext": msg.html, "createdatetime": datetime.now(), "updatedatetime": datetime.now() }) return jsonify({ "status": 200, "response": {}, "message": "mail id exist but not verified yet verification mail sent", "error": True, "registedfrom": registeredfrom }) elif regtype != 0: verify = False user = list(User.find({"email": email}, {"_id": 0})) if regtype == 1 and user[0]['registeredfrom'] == "facebook": verify = True elif regtype == 2 and user[0]['registeredfrom'] == "gmail": verify = True else: message = "account already registered from " + user[0][ 'registeredfrom'] return jsonify({ "status": 200, "messsage": message, "registedfrom": user[0]['registeredfrom'], "response": {}, "error": True }) #user = list(User.find({"email": email}, {"_id": 0})) if verify == True: #print(userdata[0]['cityname'][0]) response = userDataResponse(email) print((response)) return jsonify({ "status": 200, "response": response, "message": "", "error": False, "registedfrom": user[0]['registeredfrom'] }) else: return jsonify({ "status": 200, "messsage": "email id already used", "response": {}, "error": True, "registedfrom": userdata[0]['registeredfrom'] }) except Exception as e: return json.dumps(e, indent=4, default=json_util.default)
def user_profile_fetch(): URL = Constants.URL imagePath = Constants.IMAGE_PATH try: # Check Authentication Key. userid = int(request.json['userid']) token = request.json['token'] otherUserId = int(request.json['messageUserid']) userdata_array = list( User.find({ "userid": otherUserId, "active": True }, {"_id": 0})) resultArray = {} responseArr = [] temp = [] reportStatus = False if len(userdata_array) > 0: for collectionInfo in userdata_array: reportedJSONdata = collectionInfo['reportedJSON'] if len(reportedJSONdata) > 0: for reportStatusData in reportedJSONdata: # print reportStatusData['byuserid'] if reportStatusData['byuserid'] == userid: reportStatus = True else: reportStatus = False reviewsDataList = list \ (JobReviews.find({"touserid" :otherUserId, "adminaction" :True, "active" : True} ,{"_id" :0})) reviewsData = [] if len(reviewsDataList) > 0: for collectionInfoReview in reviewsDataList: userdata = User.find_one( { "userid": collectionInfoReview['userid'], "active": True }, {"_id": 0}) if userdata is not None: fullname = userdata['firstname'] + ' ' + userdata[ 'lastname'] if userdata['picurl'] != "": picurl = URL + imagePath + userdata['picurl'] else: picurl = URL + imagePath + "user-no-image.jpg" if collectionInfoReview.has_key('jobid'): jobData = Jobs.find_one( { "jobid": collectionInfoReview['jobid'], "active": True }, {"_id": 0}) if jobData is not None: title = jobData['title'] else: title = "" editionData = { "fullname": fullname, "jobtitle": title, "picurl": picurl } collectionInfoReview.update(editionData) reviewsData.append(collectionInfoReview) else: reviewsData = [] locationName = "" cityName = "" if collectionInfo['addressJSON']['city'] != "": citynamedata = CityCollections.find_one( {"cityid": int(collectionInfo['addressJSON']['city'])}, {"_id": 0}) cityName = citynamedata['city'] countrynamedata = CityCollections.find_one( {"countryid": int(citynamedata['countryid'])}, {"_id": 0}) print(countrynamedata) #return jsonify({"ok": 1}) countryName = countrynamedata['countryid'] else: cityName = "" countryName = "" if collectionInfo['locationid'] != "": locationNameData = Locations.find_one( {"locationid": int(collectionInfo['locationid'])}, { "_id": 0, "locationname": 1, "under": 1 }) if locationNameData is not None: if locationNameData['under'] != "": locationName = str(locationNameData['under'] ) +" - " +str \ (locationNameData['locationname']) else: locationName = str( locationNameData['locationname']) else: locationName = "" allCityData = list( CityCollections.find({}, { "_id": 0, "cityid": 1, "city": 1 })) # allcity = [] # if len(allCityData) > 0: # for getAllCityData in allCityData: # allcity.append({"cityid" : getAllCityData['cityid'], "city" : getAllCityData['city']}) skillData = collectionInfo['skillsJSON'] skillNameData = [] if len(skillData) > 0: for skillDataCollections in skillData: skillNameData.append(skillDataCollections['skillname']) rating = 0 # Rating Initially 0 userReview = list( JobReviews.find( { "touserid": int(collectionInfo['userid']), "active": True }, { "_id": 0, "rating": 1 })) if len(userReview) > 0: totalUserReview = len(userReview) if userReview is not None: for userRating in userReview: rating = rating + userRating['rating'] tatalRating = int(rating / totalUserReview) else: tatalRating = 0 portfolioData = list( UserPortfolio.find( { "userid": otherUserId, "active": True, }, {"_id": 0})) picurlPath = URL + imagePath + collectionInfo['picurl'] documentsPath = URL + Constants.DOC_PATH portfolioDataPath = URL + Constants.PORTFOLIO_PATH updateJSON = { "cityname": cityName, "locationName": locationName, "countryname": countryName, "allcity": allCityData, "skillName": skillNameData, "reviewsData": reviewsData, "portfolioData": portfolioData, "reportStatus": reportStatus, "picurlPath": picurlPath, "userrating": tatalRating, "documentsPath": documentsPath, "portfolioDataPath": portfolioDataPath } collectionInfo.update(updateJSON) responseArr.append(collectionInfo) resultArray['data'] = responseArr resultArray['status'] = "200" resultArray['message'] = "Userdata List." else: resultArray['data'] = responseArr resultArray['status'] = "400" resultArray['message'] = "No data in List." return jsonify(resultArray) except Exception as e: print(e) return jsonify({"status": 500})
def user_update(): try: userid = int(request.json['userid']) token = request.json['token'] location = request.json['location'] if location != "": location = int(location) find_user = User.find_one({"userid": userid, "active": True}) if find_user is not None: skills = request.json['skills'] print(skills) print(type(skills)) if request.json['dob'] != "": birth = request.json['dob'] print(birth) format = '%d-%m-%Y' dob = datetime.datetime.strptime(birth, format) else: dob = "" if request.json['city'] != "": citydetail = CityCollections.find_one( {"cityid": int(request.json['city'])}, {"_id": 0}) addressJSON = { "address1": request.json['address1'], "address2": request.json['address2'], "city": int(request.json['city']), "state": citydetail['stateid'], "country": citydetail['countryid'], "pincode": request.json['pincode'] } else: addressJSON = { "address1": request.json['address1'], "address2": request.json['address2'], "city": "", "state": "", "country": "", "pincode": request.json['pincode'] } if request.json['isdcode'] != "" and request.json[ 'isdcode'] is not None: isdcode = int(request.json['isdcode']) else: isdcode = "" # locationData = location.find_one({"cityid" : int(request.json['city'])},{"_id":0,"locationid":1}) # skillsJSON = [] # for skillDataJSON in skills: # stringData = '.*'+skillDataJSON+'.*' # skillsData = skills.find_one({"skillname" : { "$regex" : skillDataJSON, "$options" : 'i' }},{"_id":0,"skillid":1,"skillname":1}) # if skillsData is not None: # for skillsCollections in skillsData : # skillDict = {"skillid" : skillsCollections['skillid'], # "skillname" : skillsCollections['skillname']} # skillsJSON.append(skillDict) randomNameForFile = "" # if request.json['imageFlag']: # randomNameForFile = "image_"+str(int(time.time()))+".jpg" # fh = open("static/images/profile/"+randomNameForFile, "wb") # fh.write(request.json['picurl'].decode('base64')) # fh.close() # languagesJSON = request.json['languagesJSON'] # educationCSV = request.json['educationCSV'] # workplaceCSV = request.json['workplaceCSV'] # certificateJSON = request.json['certificateJSON'] # reportedJSON = list(report.find({ "userid" : userid, "token" : token }, {"_id":0})) if find_user['mobile'] != str(request.json['mobile']): User.update({"userid": userid}, { "$set": { "signupJSON.mobile": str(request.json['mobile']), "mobile": str(request.json['mobile']), "mobileverified": False, "proJSON.mobileverified": False } }) if find_user['email'] != str(request.json['email']): User.update({"userid": userid}, { "$set": { "signupJSON.email": str(request.json['email']), "email": str(request.json['email']), "emailverified": False } }) result = User.update({"userid": userid}, { "$set": { "firstname": request.json['firstname'], "lastname": request.json['lastname'], "aboutme": request.json['aboutme'], "languagesJSON": [], "educationCSV": [], "workplaceCSV": [], "updateddatetime": datetime.datetime.now(), "isdcode": isdcode, "addressJSON": addressJSON, "skillsJSON": skills, "gender": request.json['gender'], "dob": dob, "locationid": location } }) userdata_array = list( User.find({ "userid": userid, "active": True }, {"_id": 0})) resultArray = {} responseArr = [] if len(userdata_array) > 0: for collectionInfo in userdata_array: # cityname = citycollections.find_one({"cityid":collectionInfo['addressJSON']['city']},{"_id":0}) # allCityData = list(CityCollections.find({}, {"_id": 0, "cityid": 1, "city": 1})) # allcity = [] # if len(allCityData) > 0: # for getAllCityData in allCityData: # allcity.append({"cityid" : getAllCityData['cityid'], "city" : getAllCityData['city']}) location_name = "" if collectionInfo['addressJSON']['city'] != "": citynamedata = CityCollections.find_one( {"cityid": collectionInfo['addressJSON']['city']}, {"_id": 0}) city_name = citynamedata['city'] countrynamedata = CountryCollections.find_one( { "countryid": collectionInfo['addressJSON']['country'] }, {"_id": 0}) country_name = countrynamedata['country'] else: city_name = "" country_name = "" if collectionInfo['locationid'] != "": location_name_data = Locations.find_one( {"locationid": int(collectionInfo['locationid'])}, { "_id": 0, "locationname": 1, "under": 1 }) if location_name_data is not None: if location_name_data['under'] != "": location_name = str( location_name_data['under']) + " - " + str( location_name_data['locationname']) else: location_name = str( location_name_data['locationname']) else: location_name = "" skill_data = collectionInfo['skillsJSON'] skillNameData = [] if len(skill_data) > 0: for skillDataCollections in skill_data: skillNameData.append( skillDataCollections['skillname']) rating = 0 # Rating Initially 0 userReview = list( JobReviews.find( { "touserid": collectionInfo['userid'], "active": True }, { "_id": 0, "rating": 1 })) if len(userReview) > 0: totalUserReview = len(userReview) if userReview is not None: for userRating in userReview: rating = rating + userRating['rating'] tatalRating = int(rating / totalUserReview) else: tatalRating = 0 allCityData = list( CityCollections.find({}, { "_id": 0, "cityid": 1, "city": 1 })) picurlPath = Constants.PROFIL_PIC_STATIC_PATH + collectionInfo[ 'picurl'] portfolioData = list( UserPortfolio.find({ "userid": userid, "active": True, }, {"_id": 0})) documentsPath = Constants.URL + Constants.DOC_PATH portfolioDataPath = Constants.URL + Constants.PORTFOLIO_PATH updateJSON = { "cityname": city_name, "locationName": location_name, "countryname": country_name, "allcity": allCityData, "skillName": skillNameData, "portfolioData": portfolioData, "picurlPath": picurlPath, "userrating": tatalRating, "documentsPath": documentsPath, "portfolioDataPath": portfolioDataPath } collectionInfo.update(updateJSON) responseArr.append(collectionInfo) resultArray['data'] = responseArr else: resultArray['data'] = responseArr return make_response( jsonify({ 'status': 200, 'message': 'Successfull Updated', 'userid': userid, 'token': token, 'updateData': responseArr }), 200) else: return make_response( jsonify({ 'status': 402, 'message': 'No User Found.', 'userid': userid, 'token': token, 'updateData': [] }), 400) except Exception as e: CommonUtils.print_exception() return make_response(jsonify({"status": 500, "message": str(e)}), 500)
def register(): try: firstname = request.json['fname'] lastname = request.json['lname'] email = request.json['email'] regtype = int(request.json['regtype']) mobile = request.json['mobile'] city = request.json['city'] skill = request.json['skill'] state = request.json['state'] country = request.json['country'] picurl = request.json['picurl'] gender = request.json['gender'] if picurl == '': picurl = "default-image.jpg" if city != "": citylist = db.city.find_one({"city": city}, {"_id": 0, "cityid": 1}) cityid = citylist['cityid'] else: cityid = "" if state != "": statelist = db.state.find_one({"state": state}, {"_id": 0, "stateid": 1}) stateid = statelist['stateid'] else: stateid = "" if country != "": countrylist = db.country.find_one({"country": country}, {"_id": 0, "countryid": 1}) countryid = countrylist['countryid'] else: countryid = "" addressJSON = { "address1": request.json['address1'], "address2": request.json['address2'], "city": cityid, "state": stateid, "country": countryid, "pincode": request.json['pincode'] } salt = CommonUtils.generateRandomName() emailhash = CommonUtils.getHashValue() token = CommonUtils.generateRandomName() password = request.json['password'] password = CommonUtils.password_hash(password, salt) sociallogin = False emailverified = False fbid = "" fbaccesstoken = "" registeredfrom = "jobwork" # return jsonify({"ok":1}) userdata = list(User.find({"email": email}, {"_id": 0})) #userdata=list(User.find_one({"email":email},{"id":0,"emailverified":1})) #return jsonify({"ok": len(userdata)}) #print(userdata[0]['emailverified']) if len(userdata)==0: print("do resigtration") userid = CommonUtils.generateRandomNo(User, "userid") User.insert({"userid": userid, "signupJSON": "", "email": email, "emailverified": emailverified, "emailhash": emailhash, "mobile": mobile, "mobileverified": False, "mobileotp": "", "isdcode": None, "fbid": fbid, "fbaccesstoken": fbaccesstoken, "password": password, "salt": salt, "token": token, "firstname": firstname, "lastname": lastname, "isadmin": False, "createddatetime": datetime.now(), "updateddatetime": datetime.now(), "addressJSON": addressJSON, "paymentdetailsJSON": [], "skillsJSON": skill, "languagesJSON": [], "educationCSV": [], "workplaceCSV": [], "certificateJSON": [], "proJSON": [], "forgotpasswordJSON": [], "gender": gender, "dob": "", "aboutme": "", "picurl": picurl, "reportedJSON": [], "notificationJSON": [], "socaillogin": sociallogin, "facebookpicurl": "", "active": True, "paypal_id": "", "registeredfrom": registeredfrom }) reset_password_link = str(URL) + "emailverify__" + str(emailhash) subject = "Your SAVEonJOBS.comAccount Email Verification" msg = Message(subject, sender=("SAVEonJOBS", "*****@*****.**"), recipients=[email]) msg.html = render_template('sample.html', name=firstname, resetLink=reset_password_link, email=email) mail.send(msg) #return jsonify({"ok": 1}) EmailTracks.insert({"emailtrackid": CommonUtils.generateRandomNo(EmailTracks, "emailtrackid"), "userid": userid, "email": email, "subject": subject, "emailtext": msg.html, "createdatetime": datetime.now(), "updatedatetime": datetime.now()}) return jsonify({"Status":200,"message":"verification mail sent"}) elif userdata[0]['emailverified']==False: emailhash=CommonUtils.getHashValue() userid = CommonUtils.generateRandomNo(User, "userid") db.user.remove({"email":email}) User.insert({"userid": userid, "signupJSON": "", "email": email, "emailverified": emailverified, "emailhash": emailhash, "mobile": mobile, "mobileverified": False, "mobileotp": "", "isdcode": None, "fbid": fbid, "fbaccesstoken": fbaccesstoken, "password": password, "salt": salt, "token": token, "firstname": firstname, "lastname": lastname, "isadmin": False, "createddatetime": datetime.now(), "updateddatetime": datetime.now(), "addressJSON": addressJSON, "paymentdetailsJSON": [], "skillsJSON": skill, "languagesJSON": [], "educationCSV": [], "workplaceCSV": [], "certificateJSON": [], "proJSON": [], "forgotpasswordJSON": [], "gender": gender, "dob": "", "aboutme": "", "picurl": picurl, "reportedJSON": [], "notificationJSON": [], "socaillogin": sociallogin, "facebookpicurl": "", "active": True, "paypal_id": "", "registeredfrom": registeredfrom }) reset_password_link = str(URL) + "emailverify__" + str(emailhash) subject = "Your SAVEonJOBS.comAccount Email Verification" msg = Message(subject, sender=("SAVEonJOBS", "*****@*****.**"), recipients=[email]) msg.html = render_template('/emailTemplates/email_verification_template.html', name=firstname, resetLink=reset_password_link, email=email) mail.send(msg) EmailTracks.insert( {"emailtrackid": CommonUtils.generateRandomNo(EmailTracks, "emailtrackid"), "userid": userid, "email": email, "subject": subject, "emailtext": msg.html, "createdatetime": datetime.now(), "updatedatetime": datetime.now()}) return jsonify({"Status": 200, "message": "verification mail sent"}) else: return jsonify({"status":202,"message":"email already exist"}) except Exception as e: print(e)