Beispiel #1
0
def invitation():
    if request.method == 'GET':
        return render_template('invitation.html')
    else:
        email = request.form['email']
        if not re.match(r'^[\w\.]+@\w+\.[\w\.]+$', email):
            return render_template('invitation.html',
                                   msg="L'adresse "
                                   "courriel n'est pas valide.")
        if len(email) == 0:
            return render_template('invitation.html',
                                   msg="Le champ 'email' "
                                   "est vide!")

        if get_database().get_user_by_email(email) is not None:
            return render_template('invitation.html',
                                   msg="Cette utilisateur"
                                   " est deja membre!")

        jeton = uuid.uuid4().hex
        get_database().save_token(email, jeton)
        url = "http://localhost:5000/creation-compte/%s" % jeton
        entete = "Invitation"
        msg = """Vous avec été invité pour devenir membre de notre site.
Veuillez appuyer sur le lien suivant afin de créer votre compte.\n
%s """ % url
        mail = Gmail()
        mail.envoyer_mail(email, entete, msg)
        return redirect('/admin')
Beispiel #2
0
def mdp_oublie():
    if request.method == 'GET':
        return render_template('forgot-password.html')
    else:
        email = request.form['email']
        if not re.match(r'^[\w\.]+@\w+\.[\w\.]+$', email):
            return render_template('forgot-password.html',
                                   msg="L'adresse "
                                   "courriel n'est pas valide.")
        if len(email) == 0:
            return render_template('forgot-password.html',
                                   msg="Le champ "
                                   "'email' est vide!")
        if get_database().get_user_by_email(email) is not None:
            jeton = uuid.uuid4().hex
            get_database().save_token(email, jeton)
            url = "http://localhost:5000/nouveau-mdp/%s" % jeton
            entete = "Nouveau mot de passe"
            msg = """Bonjour,\n
Veuillez appuyer sur le lien suivant afin de créer un nouveau mot de passe.\n
%s """ % url
            mail = Gmail()
            mail.envoyer_mail(email, entete, msg)
        return redirect('/admin')