@app.route('/forgot-password', methods=['POST'])
@cross_origin(supports_credentials=True)
def send_email():
    data = request.get_json()
    user = User.query.filter_by(email=data['email']).first()
    if (not user):
        return (jsonify({'message': 'Email não encontrado!'}), 400)
    password = str(user.email).encode('UTF-8')
    passToken = bcrypt.hashpw(password, bcrypt.gensalt())
    passToken = re.sub('\\W+', '', str(passToken))
    passExpires = str((datetime.datetime.utcnow() + datetime.timedelta(minutes=15)))
    user.passwordResetToken = passToken
    user.passwordResetExpires = passExpires
    db.session.commit()
    msg = Message('Recuperação de senha - Gama Sports', sender=app.config['MAIL_USERNAME'], recipients=[user.email])
    msg.body = ((((('Olá ' + str(user.email)) + ', \n\n') + 'Acesse o link a seguir para trocar sua senha: \n\n') + 'http://localhost:4200/users/recover-password?token=') + str(passToken))
    mail.send(msg)
    return (jsonify({'message': 'Email disparado!'}), 200)
@app.route('/forgot-password', methods=['POST'])
@cross_origin(supports_credentials=True)
def send_email():
    data = request.get_json()
    user = User.query.filter_by(email=data['email']).first()
    if (not user):
        return (jsonify({'message': 'Email não encontrado!'}), 400)
    password = str(user.email).encode('UTF-8')
    passToken = bcrypt.hashpw(password, bcrypt.gensalt())
    passToken = re.sub('\\W+', , str(passToken))
    passExpires = str((datetime.datetime.utcnow() + datetime.timedelta(minutes=15)))
    user.passwordResetToken = passToken
    user.passwordResetExpires = passExpires
    db.session.commit()
    msg = Message('Recuperação de senha - Gama Sports', sender=app.config['MAIL_USERNAME'], recipients=[user.email])
    msg.body = ((((('Olá ' + str(user.email)) + ', \n\n') + 'Acesse o link a seguir para trocar sua senha: \n\n') + 'http://localhost:4200/users/recover-password?token=') + str(passToken))
    mail.send(msg)
    return (jsonify({'message': 'Email disparado!'}), 200)