Ejemplo n.º 1
0
def forgot_password():
    form = ForgotPasswordForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        new_password = _generate_password(user)
        user.set_password(new_password)

        message = Message(subject="Notejam password",
                          body="Your new password is {}".format(new_password),
                          sender="*****@*****.**",
                          recipients=[user.email])
        mail.send(message)

        db.session.commit()
        flash("Find new password in your inbox", 'success')
        return redirect(url_for('.home'))
    return render_template('users/forgot_password.html', form=form)
Ejemplo n.º 2
0
def forgot_password():
    form = ForgotPasswordForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        new_password = _generate_password(user)
        user.set_password(new_password)

        message = Message(
            subject="Notejam password",
            body="Your new password is {}".format(new_password),
            sender="*****@*****.**",
            recipients=[user.email]
        )
        mail.send(message)

        db.session.commit()
        flash("Find new password in your inbox", 'success')
        return redirect(url_for('home'))
    return render_template('users/forgot_password.html', form=form)