Validation 26/02/22 - 16h21
parent
b0bfde9fa0
commit
b772c25960
|
@ -921,7 +921,6 @@ def get_partner_class(diction):
|
|||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
|
||||
'''
|
||||
Gestion des filters.
|
||||
'''
|
||||
|
|
|
@ -452,11 +452,11 @@ def update_user_account(diction):
|
|||
# field_list.
|
||||
'''
|
||||
field_list = ['adr_street', 'adr_city', 'adr_zip', 'adr_country', 'mob_phone','link_facebook',
|
||||
'link_twitter', 'token', 'surname', 'last_name', 'birthday']
|
||||
'link_twitter', 'token', 'surname', 'last_name', 'birthday','link_linkedin']
|
||||
incom_keys=diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(" Le champ '"+val+"' n'existe pas, MAJ annulée")
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le champ '"+val+"' n'est pas autorisé ")
|
||||
return False, "Impossible de mettre à jour le compte utilisateur"
|
||||
|
||||
'''
|
||||
|
@ -519,15 +519,19 @@ def update_user_account(diction):
|
|||
|
||||
if ("surname" in diction.keys()):
|
||||
if (str(diction['surname'])):
|
||||
mysurname = str(diction['surname'])
|
||||
dictionnary['surname'] = str(diction['surname'])
|
||||
|
||||
if ("last_name" in diction.keys()):
|
||||
if (str(diction['last_name'])):
|
||||
mylast_name = str(diction['last_name'])
|
||||
dictionnary['last_name'] = str(diction['last_name'])
|
||||
|
||||
if ("birthday" in diction.keys()):
|
||||
if (str(diction['birthday'])):
|
||||
mybirthday = str(diction['birthday'])
|
||||
dictionnary['birthday'] = str(diction['birthday'])
|
||||
|
||||
if ("link_linkedin" in diction.keys()):
|
||||
if (str(diction['link_linkedin'])):
|
||||
dictionnary['link_linkedin'] = str(diction['link_linkedin'])
|
||||
|
||||
|
||||
|
||||
|
@ -649,7 +653,8 @@ def get_user_account(diction):
|
|||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
mycommon.myprint(str(e))
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de recuperer le user account"
|
||||
|
||||
|
||||
|
@ -657,7 +662,7 @@ def get_user_account(diction):
|
|||
'''
|
||||
changement du mot de passe d'un user
|
||||
'''
|
||||
def change_uer_pwd(diction):
|
||||
def change_user_pwd(diction):
|
||||
try:
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token','new_pwd']
|
||||
|
|
6
main.py
6
main.py
|
@ -625,13 +625,13 @@ Cette API met à jour le password d'un user
|
|||
'''
|
||||
Recuperation de l'historique de recherche d'un user
|
||||
'''
|
||||
@app.route('/myclass/api/change_uer_pwd/', methods=['POST','GET'])
|
||||
@app.route('/myclass/api/change_user_pwd/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def change_uer_pwd():
|
||||
def change_user_pwd():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### payload = ",payload)
|
||||
status, retval = eua.change_uer_pwd(payload)
|
||||
status, retval = eua.change_user_pwd(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
|
38
partners.py
38
partners.py
|
@ -292,42 +292,23 @@ def valide_partnair_account(value):
|
|||
print(" ########## Email = "+str(tmp[0]['email']))
|
||||
print(" ########## recid = " + str(tmp[0]['recid']))
|
||||
|
||||
# A ce niveau le login et passe sont ok.
|
||||
# il faut donc créer le token et renvoyer le token.
|
||||
my_token = mycommon.create_token_urlsafe()
|
||||
|
||||
now = datetime.now()
|
||||
ret_val = coll_name.find_and_modify(query={'_id':ObjectId(str(value)), 'locked':'0'},
|
||||
update={"$set":
|
||||
{'active': "1","date_update":str(now)}
|
||||
{'active': "1","date_update":str(now), 'token':str(my_token)}
|
||||
}
|
||||
)
|
||||
|
||||
if( ret_val and ret_val['_id']):
|
||||
mycommon.myprint("La modif a bien ete faite ="+str(ret_val['_id']))
|
||||
|
||||
# A ce niveau le login et passe sont ok.
|
||||
# il faut donc créer le token et renvoyer le token.
|
||||
my_token = mycommon.create_token_urlsafe()
|
||||
|
||||
# Enregistrement du token
|
||||
dbname2 = client['cherifdb']
|
||||
token_collection = dbname2['user_token']
|
||||
|
||||
tokenfield = {}
|
||||
tokenfield['token'] = my_token
|
||||
tokenfield['email'] = str(tmp[0]['email'])
|
||||
tokenfield['recid'] = str(tmp[0]['recid'])
|
||||
tokenfield['date_update'] = str(datetime.now())
|
||||
tokenfield['valide'] = '1'
|
||||
|
||||
ret_val = token_collection.insert_one(tokenfield)
|
||||
if ret_val and ret_val.inserted_id:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Ajout Token OK, _id = " + str(ret_val.inserted_id))
|
||||
return 'True', my_token
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible d'enregistrer le token " + my_token)
|
||||
return False, "Impossible de valider le compte"
|
||||
mycommon.myprint("La modif a bien ete faite Ajout Token OK, ="+str(ret_val['_id']))
|
||||
return 'True', my_token
|
||||
|
||||
else:
|
||||
mycommon.myprint(" Aucune modif n'a été faite")
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucune modif n'a été faite")
|
||||
return False, "Impossible de valider le compte"
|
||||
|
||||
|
||||
|
@ -460,8 +441,6 @@ def partner_login(diction):
|
|||
if diction['pwd']:
|
||||
pwd = diction['pwd']
|
||||
|
||||
|
||||
|
||||
if ("secret" in diction.keys()):
|
||||
if diction['secret']:
|
||||
token = diction['secret']
|
||||
|
@ -485,6 +464,7 @@ def partner_login(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " Connexion partener "+email+" : OK, Date : "+ str(now)+" , _id = " + str(ret_val['_id']))
|
||||
# Vu que les credentials sont ok, alors enregistrement de la connexion dans la table "partner token"
|
||||
|
||||
#print(" GRRRRRRRRRRRRRRRRRRR "+str(ret_val))
|
||||
mydata['recid'] = str(ret_val['recid'])
|
||||
token_collection = dbname['partner_token']
|
||||
|
||||
|
|
Loading…
Reference in New Issue