05/08/22 - 14h30
parent
f57e41fc35
commit
399bafcc63
273
email_mgt.py
273
email_mgt.py
|
@ -269,10 +269,10 @@ def send_partner_account_mail(message, account_mail):
|
|||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
receiver = ["cherif.balde@yahoo.fr","cbalde@bigben-connected.com",str(account_mail)]
|
||||
receiver = [str(account_mail)]
|
||||
toaddrs = ", ".join(receiver)
|
||||
|
||||
print(" mail enoye à : "+toaddrs)
|
||||
print(" mail enoye à toaddrs : "+toaddrs)
|
||||
|
||||
|
||||
print("debut envoi mail de test ")
|
||||
|
@ -280,39 +280,118 @@ def send_partner_account_mail(message, account_mail):
|
|||
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg['Subject'] = 'MySy : test email activation compte '
|
||||
msg['Subject'] = '[MySy Training]: activation de votre compte PRO'
|
||||
msg['From'] = 'contact@mysy-training.com'
|
||||
msg['To'] = str(toaddrs)
|
||||
msg['Cc'] = 'cbalde@mysy-training.com'
|
||||
msg['Cc'] = 'contact@mysy-training.com'
|
||||
|
||||
print(" mail enoye à toaddrs : " + str(msg['To']))
|
||||
|
||||
html = '''
|
||||
<html>
|
||||
<body>
|
||||
<p>Bonjour</p>
|
||||
<p>Vous venez de créer un compte partenaire.
|
||||
Pour activier votre compte, merci de cliquer ici </b> </p>
|
||||
<b>
|
||||
<a href="https://apimysy.iexercice.com/myclass/api/valide_partnair_account/{objId}" target="_blank" >
|
||||
https://apimysy.iexercice.com/myclass/api/valide_partnair_account/{objId}
|
||||
</b>
|
||||
</a>
|
||||
|
||||
<a>
|
||||
ou
|
||||
<b>
|
||||
<a href="http://127.0.0.1:5000/myclass/api/valide_partnair_account/{objId}" target="_blank" >
|
||||
http://127.0.0.1:5000/myclass/api/valide_partnair_account/{objId}
|
||||
</b>
|
||||
</a>
|
||||
<p>Cordialement<br>
|
||||
L'equipe informatique de MySy
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
'''.format(code=tomorrow_day, objId=message)
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="http://88.170.110.220/mysy_css/mysy_css.css">
|
||||
</head>
|
||||
<body>
|
||||
<div style="background-color:#eee;padding:0px;text-align:center;width:100%">
|
||||
<h2 style="font-family:Georgia, 'Times New Roman', Times, serif;color#454349;">
|
||||
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="110px" height="70px"/> </h2>
|
||||
</div>
|
||||
<div style="padding:20px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:2rem;">
|
||||
<div style="width:100%">
|
||||
<div style="text-align:left;" class="p">
|
||||
Bonjour
|
||||
<div style="padding:20px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:1.2rem;">
|
||||
|
||||
Vous venez de créer votre <font color="red"> compte PRO </font> sur le moteur de recherche <font color="green">MySy-Training</font>. <br>
|
||||
le processus de création du <font color="red"> compte PRO </font> sur mysy-training.com s'est déroulé avec succès.<br/>
|
||||
<p>
|
||||
La securité des vos données est primordiale pour nous. Une fois que vous aurez activez votre compte vous allez recevoir :
|
||||
<li>
|
||||
Une clé secrète </li>
|
||||
<li>
|
||||
Un nouveau mot de passe. Nous vous invitons à changer ce mot de passe depuis votre nouvelle espace PRO.
|
||||
</li>
|
||||
|
||||
</p>
|
||||
Pour activer votre compte, veuillez cliquer sur le lien ci-dessous :
|
||||
<br/><br/>
|
||||
<div style="background-color:#1962AB;width:20%;text-align:center;margin-left:auto; margin-right:auto;">
|
||||
<b> <a href="https://apimysy.iexercice.com/myclass/api/valide_partnair_account/{objId}" target="_blank" style="color: white;">
|
||||
CLIQUEZ ICI
|
||||
|
||||
</a>
|
||||
</b>
|
||||
</div>
|
||||
|
||||
<br/><br/>
|
||||
<div style="background-color:#1962AB;width:20%;text-align:center;margin-left:auto; margin-right:auto;">
|
||||
<b> <a href="http://127.0.0.1:5000/myclass/api/valide_partnair_account/{objId}" target="_blank" style="color: white;">
|
||||
CLIQUEZ ICI (local)
|
||||
|
||||
</a>
|
||||
</b>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
Important : Pour vous connecter entant que PRO sur le site mysy-training.com, la clé secrete et le mot de passe sont necessaires.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Merci d'avoir rejoint MySy.
|
||||
Cordialement.
|
||||
</p>
|
||||
|
||||
<br/>
|
||||
MySy Training Technology<br/>
|
||||
Contact : +337 69 20 39 45<br/>
|
||||
Email : contact@mysy-training.com<br/>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
<b> Suivez l'actualité des formations depuis nos medias : <br/>
|
||||
|
||||
<a href="https://www.facebook.com/MySy-Training-114572794561371/" target="_blank" >
|
||||
Facebook
|
||||
</a>
|
||||
|
||||
<a href="https://www.linkedin.com/" target="_blank" >
|
||||
LinkedIn
|
||||
</a>
|
||||
|
||||
<a href="https://www.linkedin.com/in/mysy-training-96b53a237/" target="_blank" >
|
||||
Twitter
|
||||
</a>
|
||||
|
||||
</b>
|
||||
</div>
|
||||
</font>
|
||||
<br/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="padding:20px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:0.9rem;">
|
||||
|
||||
Ce mail a été envoyé à : {destinataire}"
|
||||
Ce mail vous est adressé par MYSY Training dont le siège social est situé au 1 Cr du Havre, 75008 Paris.
|
||||
Conformément à la Loi Informatique et Liberté Loi n° 78-17 du 6 janvier 1978 modifiée et au Règlement Général sur la Protection des Données Règlement (UE) 2016/679 du Parlement européen et du Conseil du 27 avril 2016 dit RGPD, vous disposez d'un droit d'accès, de rectification, d'effacement, de limitation et d'opposition au traitement de vos données. Vous pouvez exercer vos droits par courrier postal envoyé à : MYSY Training 1 Cr du Havre, 75008 Paris ou par mail : contact@mysy-training.com.
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
'''.format(code=tomorrow_day, objId=message, destinataire=account_mail)
|
||||
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
|
@ -580,4 +659,138 @@ def SendGenericEmail(mail_recever=None, mail_object=None, mail_message=None):
|
|||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
'''
|
||||
Apres l'activation du compte pro,
|
||||
cet email envoie le token et mot de passe temporaire à l'utilisateur
|
||||
'''
|
||||
def Pro_Account_Token_Pass(account_mail, my_token, my_tmp_pwd):
|
||||
try:
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
receiver = [str(account_mail)]
|
||||
toaddrs = ", ".join(receiver)
|
||||
|
||||
print(" mail enoye à toaddrs : " + toaddrs)
|
||||
print("debut envoi mail de test ")
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg['Subject'] = '[MySy Training]: votre compte PRO est pret'
|
||||
msg['From'] = 'contact@mysy-training.com'
|
||||
msg['To'] = str(toaddrs)
|
||||
msg['Cc'] = 'contact@mysy-training.com'
|
||||
|
||||
tmp_pwd = my_tmp_pwd
|
||||
cle = my_token
|
||||
|
||||
print(" mail enoye à toaddrs : " + str(msg['To']))
|
||||
html = ''' <!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="http://88.170.110.220/mysy_css/mysy_css.css">
|
||||
</head>
|
||||
<body>
|
||||
<div style="background-color:#eee;padding:0px;text-align:center;width:100%">
|
||||
<h2 style="font-family:Georgia, 'Times New Roman', Times, serif;color#454349;">
|
||||
<img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="110px" height="70px"/> </h2>
|
||||
</div>
|
||||
<div style="padding:20px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:2rem;">
|
||||
<div style="width:100%">
|
||||
<div style="text-align:left;" class="p">
|
||||
Bonjour
|
||||
<div style="padding:20px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:1.2rem;">
|
||||
|
||||
Vous venez d'activer votre <font color="red"> compte PRO </font> sur le moteur de recherche <font color="green">MySy-Training</font>. <br>
|
||||
<br>
|
||||
Pour vous connecter et profiter de nos services, voici vos identifiants :
|
||||
<p>
|
||||
|
||||
<li>
|
||||
Votre clé secrète : {cle} </li>
|
||||
<li>
|
||||
Votre mot de passe temporaire : {tmp_pwd}<br>
|
||||
<i>Nous vous recommandons de changer ce mot de passe apres la première connection.</i>
|
||||
</li>
|
||||
<li>
|
||||
url de connexion : https://www.mysy-training.com/PartnerLogin
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
Merci d'avoir rejoint MySy.
|
||||
Cordialement.
|
||||
</p>
|
||||
|
||||
<br/>
|
||||
MySy Training Technology<br/>
|
||||
Contact : +337 69 20 39 45<br/>
|
||||
Email : contact@mysy-training.com<br/>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
<b> Suivez l'actualité des formations depuis nos medias : <br/>
|
||||
|
||||
<a href="https://www.facebook.com/MySy-Training-114572794561371/" target="_blank" >
|
||||
Facebook
|
||||
</a>
|
||||
|
||||
<a href="https://www.linkedin.com/" target="_blank" >
|
||||
LinkedIn
|
||||
</a>
|
||||
|
||||
<a href="https://www.linkedin.com/in/mysy-training-96b53a237/" target="_blank" >
|
||||
Twitter
|
||||
</a>
|
||||
|
||||
</b>
|
||||
</div>
|
||||
</font>
|
||||
<br/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="padding:20px 0px;text-align:left;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:0.9rem;">
|
||||
|
||||
Ce mail a été envoyé à : {destinataire}"
|
||||
Ce mail vous est adressé par MYSY Training dont le siège social est situé au 1 Cr du Havre, 75008 Paris.
|
||||
Conformément à la Loi Informatique et Liberté Loi n° 78-17 du 6 janvier 1978 modifiée et au Règlement Général sur la Protection des Données Règlement (UE) 2016/679 du Parlement européen et du Conseil du 27 avril 2016 dit RGPD, vous disposez d'un droit d'accès, de rectification, d'effacement, de limitation et d'opposition au traitement de vos données. Vous pouvez exercer vos droits par courrier postal envoyé à : MYSY Training 1 Cr du Havre, 75008 Paris ou par mail : contact@mysy-training.com.
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
'''.format(code=tomorrow_day, destinataire=account_mail, cle=cle, tmp_pwd=tmp_pwd)
|
||||
html_mime = MIMEText(html, 'html')
|
||||
|
||||
# msg.attach(texte_mime)
|
||||
msg.attach(html_mime)
|
||||
|
||||
print("html_mime =" + str(html))
|
||||
|
||||
with smtplib.SMTP(smtp_address, port) as server:
|
||||
server.starttls() # Secure the connection
|
||||
|
||||
server.login(user, password)
|
||||
server.sendmail(sender, toaddrs, msg.as_string())
|
||||
print("mail successfully sent")
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
|
|
12
main.py
12
main.py
|
@ -502,10 +502,14 @@ def valide_partnair_account(value):
|
|||
print(" ### validation du compte = ",value)
|
||||
result, token = pa.valide_partnair_account(value)
|
||||
|
||||
if result:
|
||||
#return jsonify(status='True', message='Votre compte a été activé')
|
||||
return "Votre Compte a été activé, le token est : "+str(token)
|
||||
return jsonify(status='False')
|
||||
if (result):
|
||||
url = 'https://www.mysy-training.com/PartnerLogin0/'
|
||||
url = 'http://localhost:3009/PartnerLogin0'
|
||||
else:
|
||||
url = 'https://www.mysy-training.com/erreur'
|
||||
|
||||
return redirect(url)
|
||||
|
||||
|
||||
|
||||
'''
|
||||
|
|
16
partners.py
16
partners.py
|
@ -530,6 +530,8 @@ def valide_partnair_account(value):
|
|||
|
||||
tmp = coll_name.find({'_id':ObjectId(str(value))})
|
||||
|
||||
partner_email = tmp[0]['email']
|
||||
|
||||
print(" ########## Email = "+str(tmp[0]['email']))
|
||||
print(" ########## recid = " + str(tmp[0]['recid']))
|
||||
|
||||
|
@ -537,15 +539,25 @@ def valide_partnair_account(value):
|
|||
# il faut donc créer le token et renvoyer le token.
|
||||
my_token = mycommon.create_token_urlsafe()
|
||||
|
||||
'''
|
||||
Create default / temporary pwd for new account
|
||||
'''
|
||||
my_tmp_pwd = 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), 'token':str(my_token)}
|
||||
{'active': "1","date_update":str(now),
|
||||
'token':str(my_token),
|
||||
'pwd':my_tmp_pwd
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if( ret_val and ret_val['_id']):
|
||||
mycommon.myprint("La modif a bien ete faite Ajout Token OK, ="+str(ret_val['_id']))
|
||||
# Envoie du mail de notification
|
||||
mail.Pro_Account_Token_Pass(partner_email, my_token, my_tmp_pwd)
|
||||
return 'True', my_token
|
||||
|
||||
else:
|
||||
|
@ -697,7 +709,7 @@ def partner_login(diction):
|
|||
coll_name = MYSY_GV.dbname['partnair_account']
|
||||
ret_val = coll_name.find_one_and_update({'email': str(email), 'pwd': str(pwd), 'token': str(token), 'active': '1', 'locked':'0'},
|
||||
{"$set": {'last_connexion':str(now)}},
|
||||
upsert=True,
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue