15/08/22 - 17h30
parent
7b60ba246c
commit
4304932f10
|
@ -386,12 +386,12 @@ def add_user_account(diction):
|
|||
# Verification que cette adresse email n'existe pas. On doit aussi verifier que cette adresse
|
||||
# n'est pas utiliser comme compte partner.
|
||||
|
||||
tmp = coll_name.count_documents({'email': str(myuser['email'])})
|
||||
tmp = coll_name.count_documents({'email': str(myuser['email']), 'active':'1'})
|
||||
if( tmp > 0 ):
|
||||
mycommon.myprint("l'adresse email '"+str(myuser['email'])+"' existe deja, impossible de créer le compte ")
|
||||
return False, "Cette adresse email est deja utilisée, impossible de créer le compte utilisateur"
|
||||
|
||||
tmp = coll_name_partnair_account.count_documents({'email': str(myuser['email'])})
|
||||
tmp = coll_name_partnair_account.count_documents({'email': str(myuser['email']), 'active':'1'})
|
||||
if (tmp > 0):
|
||||
mycommon.myprint(
|
||||
"l'adresse email '" + str(myuser['email']) + "' existe deja (compte utiliser comme partner), impossible de créer le compte ")
|
||||
|
@ -804,7 +804,7 @@ avec un token de reinitialisation '''
|
|||
def Reset_user_pwd_by_token(diction):
|
||||
try:
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'new_pwd', 'conf_new_pwd']
|
||||
field_list = ['token', 'new_pwd', 'conf_new_pwd', 'accounttype']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -815,7 +815,7 @@ def Reset_user_pwd_by_token(diction):
|
|||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token', 'new_pwd', 'conf_new_pwd']
|
||||
field_list_obligatoire = ['token', 'new_pwd', 'conf_new_pwd', 'accounttype']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(" La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
|
@ -828,6 +828,7 @@ def Reset_user_pwd_by_token(diction):
|
|||
pwd = ""
|
||||
new_pwd = ""
|
||||
conf_new_pwd = ""
|
||||
accounttype = ""
|
||||
|
||||
mydata ={}
|
||||
|
||||
|
@ -844,64 +845,123 @@ def Reset_user_pwd_by_token(diction):
|
|||
new_pwd = diction['new_pwd']
|
||||
mydata['pwd'] = diction['new_pwd']
|
||||
|
||||
|
||||
# Verification de la validité du token/mail dans le cas des user en mode connecté
|
||||
if ( len(str(token_value)) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le token est vide")
|
||||
return False, "Le token est vide"
|
||||
|
||||
if ( len(str(new_pwd)) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le mot de passe est vide")
|
||||
return False, "Le mot de passe est vide"
|
||||
if ("accounttype" in diction.keys()):
|
||||
if diction['accounttype']:
|
||||
accounttype = diction['accounttype']
|
||||
|
||||
|
||||
if (str(new_pwd) != str(conf_new_pwd)):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Les mots de passe ne sont pas identiques. nouveau pass :'"+str(new_pwd) +"', la oonfirmation envoyées est "''+str(conf_new_pwd)+"' ")
|
||||
return False, " Les mots de passe ne sont pas identiques "
|
||||
if( accounttype == "1"):
|
||||
#Traitement d'un user classique
|
||||
# Verification de la validité du token/mail dans le cas des user en mode connecté
|
||||
if ( len(str(token_value)) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le token est vide")
|
||||
return False, "Le token est vide"
|
||||
|
||||
retval = mycommon.check_token_validity("", token_value)
|
||||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le token est invalide")
|
||||
return False, "Le token est invalide"
|
||||
if ( len(str(new_pwd)) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le mot de passe est vide")
|
||||
return False, "Le mot de passe est vide"
|
||||
|
||||
|
||||
# Recuperation du recid du user
|
||||
user_recid = mycommon.get_user_recid_from_token(token_value)
|
||||
if user_recid is False :
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de recuperer le recid du user. Le token envoyé est :"+str(token_value))
|
||||
return False, " Impossible de mettre à jour le mot de passe"
|
||||
if (str(new_pwd) != str(conf_new_pwd)):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Les mots de passe ne sont pas identiques. nouveau pass :'"+str(new_pwd) +"', la oonfirmation envoyées est "''+str(conf_new_pwd)+"' ")
|
||||
return False, " Les mots de passe ne sont pas identiques "
|
||||
|
||||
retval = mycommon.check_token_validity("", token_value)
|
||||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le token est invalide")
|
||||
return False, "Le token est invalide"
|
||||
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
dbname = client['cherifdb']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
# Recuperation du recid du user
|
||||
user_recid = mycommon.get_user_recid_from_token(token_value)
|
||||
if user_recid is False :
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de recuperer le recid du user. Le token envoyé est :"+str(token_value))
|
||||
return False, " Impossible de mettre à jour le mot de passe"
|
||||
|
||||
print(" le recid = "+user_recid+" mydata = "+str(mydata))
|
||||
ret_val = coll_name.find_one_and_update({'recid': user_recid, 'locked': '0', 'active':'1'},
|
||||
{"$set": mydata},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
# Apres avoir changer le mot passe, desactivation tu token
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
dbname = client['cherifdb']
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
coll_name = MYSY_GV.dbname['user_token']
|
||||
ret_val = coll_name.update_many({'recid': user_recid, 'valide': '1'},
|
||||
{"$set": {'valide': '0', 'date_update': str(datetime.now())}},
|
||||
)
|
||||
print(" le recid = "+user_recid+" mydata = "+str(mydata))
|
||||
ret_val = coll_name.find_one_and_update({'recid': user_recid, 'locked': '0', 'active':'1'},
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if( ret_val.matched_count <= 0 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " WARNING : Attention à la mise à jour du mot de passe de"
|
||||
" du user avec le recid = "+user_recid)
|
||||
if (ret_val and ret_val['_id']):
|
||||
# Apres avoir changer le mot passe, desactivation tu token
|
||||
|
||||
coll_name = MYSY_GV.dbname['user_token']
|
||||
ret_val = coll_name.update_many({'recid': user_recid, 'valide': '1'},
|
||||
{"$set": {'valide': '0', 'date_update': str(datetime.now())}},
|
||||
)
|
||||
|
||||
if( ret_val.matched_count <= 0 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " WARNING : Attention à la mise à jour du mot de passe de"
|
||||
" du user avec le recid = "+user_recid)
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le mot de passe de l'utilisateur (recid) =" + str(user_recid)+" a été modifié")
|
||||
return True, "Le mot de passe a bien été mise à jour "
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le mot de passe de l'utilisateur (recid) =" + str(user_recid)+" a été modifié")
|
||||
return True, "Le mot de passe a bien été mise à jour "
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de mettre à jour le password du user : recid = "+str(user_recid))
|
||||
return False, "Impossible de mettre à jour le password"
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de mettre à jour le password du user : recid = "+str(user_recid))
|
||||
return False, "Impossible de mettre à jour le password"
|
||||
|
||||
elif( accounttype == "2"):
|
||||
# Traitement d'un compte pro
|
||||
# Verification de la validité du token/mail dans le cas des user en mode connecté
|
||||
if (len(str(token_value)) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le token est vide")
|
||||
return False, "Le token est vide"
|
||||
|
||||
if (len(str(new_pwd)) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le mot de passe est vide")
|
||||
return False, "Le mot de passe est vide"
|
||||
|
||||
if (str(new_pwd) != str(conf_new_pwd)):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Les mots de passe ne sont pas identiques. nouveau pass :'" + str(
|
||||
new_pwd) + "', la oonfirmation envoyées est "'' + str(conf_new_pwd) + "' ")
|
||||
return False, " Les mots de passe ne sont pas identiques "
|
||||
|
||||
"""
|
||||
/!\ ATTENTION : Pour les pro, on verifie le champ : "tmp_token_pwd" qui est token temporaire generé
|
||||
pour le lien de reinitialisation.
|
||||
|
||||
"""
|
||||
tmp_retval = MYSY_GV.dbname['partnair_account'].find({'tmp_token_pwd':token_value, 'active':'1'})
|
||||
if tmp_retval is False or tmp_retval[0] is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le token est invalide")
|
||||
return False, "Le token est invalide"
|
||||
|
||||
# Recuperation du recid du user
|
||||
user_recid = tmp_retval[0]['recid']
|
||||
mydata = {}
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['pwd'] = new_pwd
|
||||
mydata['tmp_token_pwd'] = ""
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
print(" le recid PARTENAIRE = " + user_recid + " mydata = " + str(mydata))
|
||||
ret_val = coll_name.find_one_and_update({'recid': user_recid, 'locked': '0', 'active': '1'},
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le mot de passe a bien été mise à jour")
|
||||
return True, "Le mot de passe a bien été mise à jour "
|
||||
else:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Impossible de mettre à jour le password du user : recid = " + str(
|
||||
user_recid))
|
||||
return False, "Impossible de mettre à jour le mot de passe"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
@ -1188,11 +1248,16 @@ def delete_user_account(diction):
|
|||
|
||||
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
ret_val = coll_name.find_one_and_update({'recid': str(user_recid), 'locked': '0'},
|
||||
ret_val = coll_name.find_one_and_update({'recid': str(user_recid)},
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
print("mydata ="+str(mydata))
|
||||
print( "user_recid = "+user_recid)
|
||||
print(str(ret_val))
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le compte utilisateur =" + str(ret_val['_id'])+" a été supprimé de la table : user_account ")
|
||||
|
@ -1485,7 +1550,7 @@ def InitUserPasswd(diction):
|
|||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['email']
|
||||
field_list = ['email', 'secrete']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -1508,71 +1573,142 @@ def InitUserPasswd(diction):
|
|||
Verification de la valider de l'email
|
||||
'''
|
||||
myemail = ""
|
||||
mysecrete = ""
|
||||
myquery = {}
|
||||
if ("email" in diction.keys()):
|
||||
if diction['email']:
|
||||
myemail = diction['email']
|
||||
myquery['email'] = diction['email']
|
||||
|
||||
if ("secrete" in diction.keys()):
|
||||
if diction['secrete']:
|
||||
mysecrete = diction['secrete']
|
||||
myquery['token'] = diction['secrete']
|
||||
|
||||
|
||||
myquery['active'] = '1'
|
||||
myquery['locked'] = '0'
|
||||
|
||||
'''
|
||||
Si le champs "secrete" est vide, alors il s'agit d'un compte utilisateur classique
|
||||
'''
|
||||
if( mysecrete == ""):
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
|
||||
coll_name = MYSY_GV.dbname['user_account']
|
||||
#print(" myquery ="+str(myquery))
|
||||
|
||||
#print(" myquery ="+str(myquery))
|
||||
tmp = coll_name.count_documents(myquery)
|
||||
if (tmp <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour " + str(myquery))
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
|
||||
retVal = coll_name.find(myquery, {"_id": 0, "valide": 0, "user_recid": 0})
|
||||
|
||||
#print(" le recid = "+str(retVal[0]['recid']))
|
||||
|
||||
'''
|
||||
Desactivation des tocken actifs
|
||||
'''
|
||||
update_field = {'valide': '0', 'date_update':str(datetime.now())}
|
||||
|
||||
|
||||
coll_name_token = MYSY_GV.dbname['user_token']
|
||||
ret_val_user_rech = coll_name_token.update_many(
|
||||
{'recid': retVal[0]['recid']},
|
||||
{"$set": update_field}
|
||||
)
|
||||
|
||||
if (ret_val_user_rech.matched_count <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de desactivier les token actifs dans table 'user_token' ")
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
|
||||
'''
|
||||
Insertion du nouveau token
|
||||
'''
|
||||
new_token = {}
|
||||
new_token['email'] = retVal[0]['email']
|
||||
new_token['recid'] = retVal[0]['recid']
|
||||
new_token['date_update'] = str(datetime.now())
|
||||
new_token['valide'] = '1'
|
||||
# Creation du token
|
||||
mynewtoken = mycommon.create_token_urlsafe()
|
||||
new_token['token'] = mynewtoken
|
||||
|
||||
|
||||
#print(" new token to insert = "+str(new_token))
|
||||
ret_val_tmp = coll_name_token.insert_one(new_token)
|
||||
if (ret_val_tmp is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de créer le nouveau toek")
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
# Account type 1 is for normal customers
|
||||
account_type = 1
|
||||
|
||||
# envoi de l'email
|
||||
email_mgt.send_user_init_pwd_mail(mynewtoken, retVal[0]['email'], account_type)
|
||||
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
elif( len(mysecrete) > 0):
|
||||
'''
|
||||
Le champs "secrete" est rempli, alors on reinitialise le pwd d'un partenaire
|
||||
'''
|
||||
|
||||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
# print(" myquery ="+str(myquery))
|
||||
|
||||
tmp = coll_name.count_documents(myquery)
|
||||
if (tmp <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour le compte pro " + str(myquery))
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
retVal = coll_name.find(myquery, {"_id": 0, "valide": 0, "user_recid": 0})
|
||||
|
||||
"""
|
||||
Dans le cas exclusif du compte pro,
|
||||
nous allons créer une token temporaire de reinitialisation, ceci sans perdre de vue que le
|
||||
token de base ne change pas.
|
||||
"""
|
||||
|
||||
new_token = {}
|
||||
new_token['date_update'] = str(datetime.now())
|
||||
# Creation du token
|
||||
mynewtoken = mycommon.create_token_urlsafe()
|
||||
new_token['tmp_token_pwd'] = mynewtoken
|
||||
|
||||
ret_val = coll_name.find_one_and_update(
|
||||
{'recid': str(retVal[0]['recid']), },
|
||||
{"$set": new_token},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val['_id'] is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " : Impossible de reinitialiser le mot de passe")
|
||||
return False, "Impossible de reinitialiser le mot de passe"
|
||||
|
||||
|
||||
ret_val_tmp = coll_name.insert_one(new_token)
|
||||
if (ret_val_tmp is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de créer le nouveau toek")
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
# Account type 2 is for PRO customers
|
||||
account_type = 2
|
||||
email_mgt.send_user_init_pwd_mail(mynewtoken, retVal[0]['email'],account_type )
|
||||
|
||||
tmp = coll_name.count_documents(myquery)
|
||||
if (tmp <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour " + str(myquery))
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
|
||||
retVal = coll_name.find(myquery, {"_id": 0, "valide": 0, "user_recid": 0})
|
||||
|
||||
#print(" le recid = "+str(retVal[0]['recid']))
|
||||
|
||||
'''
|
||||
Desactivation des tocken actifs
|
||||
'''
|
||||
update_field = {'valide': '0', 'date_update':str(datetime.now())}
|
||||
|
||||
|
||||
coll_name_token = MYSY_GV.dbname['user_token']
|
||||
ret_val_user_rech = coll_name_token.update_many(
|
||||
{'recid': retVal[0]['recid']},
|
||||
{"$set": update_field}
|
||||
)
|
||||
|
||||
if (ret_val_user_rech.matched_count <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de desactivier les token actifs dans table 'user_token' ")
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
|
||||
'''
|
||||
Insertion du nouveau token
|
||||
'''
|
||||
new_token = {}
|
||||
new_token['email'] = retVal[0]['email']
|
||||
new_token['recid'] = retVal[0]['recid']
|
||||
new_token['date_update'] = str(datetime.now())
|
||||
new_token['valide'] = '1'
|
||||
# Creation du token
|
||||
mynewtoken = mycommon.create_token_urlsafe()
|
||||
new_token['token'] = mynewtoken
|
||||
|
||||
|
||||
#print(" new token to insert = "+str(new_token))
|
||||
ret_val_tmp = coll_name_token.insert_one(new_token)
|
||||
if (ret_val_tmp is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de créer le nouveau toek")
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
# envoi de l'email
|
||||
email_mgt.send_user_init_pwd_mail(mynewtoken, retVal[0]['email'])
|
||||
|
||||
return True, "La demande de reinitiation à été prise en compte"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
@ -1591,7 +1727,7 @@ def IsUserTokenValide(diction):
|
|||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token']
|
||||
field_list = ['token', 'accounttype']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -1603,7 +1739,7 @@ def IsUserTokenValide(diction):
|
|||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token']
|
||||
field_list_obligatoire = ['token', 'accounttype']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
|
@ -1614,14 +1750,36 @@ def IsUserTokenValide(diction):
|
|||
if diction['token']:
|
||||
myquery['token'] = diction['token']
|
||||
|
||||
myquery['valide'] = '1'
|
||||
coll_name_token = MYSY_GV.dbname['user_token']
|
||||
myaccounttype = ""
|
||||
if ("accounttype" in diction.keys()):
|
||||
if diction['accounttype']:
|
||||
myaccounttype = diction['accounttype']
|
||||
|
||||
|
||||
tmp = coll_name_token.count_documents(myquery)
|
||||
if (tmp <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour " + str(myquery))
|
||||
return False, "Le token n'est pas valide"
|
||||
|
||||
if( myaccounttype == "1"):
|
||||
myquery['valide'] = '1'
|
||||
# il s'agit d'un compte utilisateur
|
||||
coll_name_token = MYSY_GV.dbname['user_token']
|
||||
|
||||
|
||||
tmp = coll_name_token.count_documents(myquery)
|
||||
if (tmp <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour " + str(myquery))
|
||||
return False, "Le token n'est pas valide"
|
||||
|
||||
elif( myaccounttype == "2"):
|
||||
# Il s'agit d'un compte pro (partenaire)
|
||||
myquery = {}
|
||||
myquery['tmp_token_pwd'] = diction['token']
|
||||
myquery['active'] = '1'
|
||||
coll_name_token = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
tmp = coll_name_token.count_documents(myquery)
|
||||
if (tmp <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucun resultat trouvé pour " + str(myquery))
|
||||
return False, "Le token n'est pas valide"
|
||||
|
||||
|
||||
return True, "Le token est valdie"
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ def send_partner_account_mail(message, account_mail):
|
|||
'''
|
||||
Envoie de l'email de reinitialisation du mot de passe du user
|
||||
'''
|
||||
def send_user_init_pwd_mail(token, account_mail):
|
||||
def send_user_init_pwd_mail(token, account_mail, type_account):
|
||||
try:
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
@ -186,9 +186,9 @@ def send_user_init_pwd_mail(token, account_mail):
|
|||
|
||||
my_url = ""
|
||||
if (MYSY_GV.MYSY_ENV == "PROD"):
|
||||
my_url = "https://www.mysy-training.com/ResetUserPwd/" + str(token)
|
||||
my_url = "https://www.mysy-training.com/ResetUserPwd/" + str(token)+"/"+str(type_account)
|
||||
elif (MYSY_GV.MYSY_ENV == "DEV"):
|
||||
my_url = "http://localhost:3009/ResetUserPwd/" + str(token)
|
||||
my_url = "http://localhost:3009/ResetUserPwd/" + str(token)+"/"+str(type_account)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -165,14 +165,14 @@ def add_partner_account(diction):
|
|||
|
||||
# Verification que cette adresse email n'existe pas. Ceci que soit entant que user ou entant que partner
|
||||
#tmp = coll_name.find({'email': str(mydata['email']) }).count()
|
||||
tmp = coll_name.count_documents({'email': str(mydata['email']) })
|
||||
tmp = coll_name.count_documents({'email': str(mydata['email']), 'active':'1' })
|
||||
|
||||
logging.info(" TMP = "+str(tmp))
|
||||
if( tmp > 0 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - l'adresse email '"+str(mydata['email'])+"' existe deja, impossible de créer le compte partenaire ")
|
||||
return False, "l'adresse email '"+str(mydata['email'])+"' est deja utilisée, impossible de créer le compte partenaire "
|
||||
|
||||
tmp = coll_name_user_account.count_documents({'email': str(mydata['email'])})
|
||||
tmp = coll_name_user_account.count_documents({'email': str(mydata['email']), 'active':'1'})
|
||||
logging.info(" TMP = " + str(tmp))
|
||||
if (tmp > 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - l'adresse email '" + str(
|
||||
|
|
|
@ -260,7 +260,7 @@ def get_user_email_from_recid(recid = ""):
|
|||
return False
|
||||
|
||||
coll_token = MYSY_GV.dbname['user_account']
|
||||
tmp_val = coll_token.find({'recid': str(recid), 'active': '1'})
|
||||
tmp_val = coll_token.find({'recid': str(recid), 'active': '0'})
|
||||
|
||||
if( tmp_val and tmp_val[0] and tmp_val[0]['email']):
|
||||
user_email = tmp_val[0]['email']
|
||||
|
|
Loading…
Reference in New Issue