@app.route('/users', methods=['POST'])
@cross_origin(supports_credentials=True)
def create_user():
    cpf = CPF()
    data = request.get_json()
    if ((not all(((x.isalpha() or x.isspace()) for x in str(data['name'])))) or (len(str(data['name'])) < 3) or (len(str(data['name'])) > 100)):
        return (jsonify({'message': 'Nome inválido!'}), 400)
    elif (not cpf.validate(str(data['cpf']))):
        return (jsonify({'message': 'CPF inválido!'}), 400)
    elif ((datetime.date.today().year - datetime.datetime.strptime(str(data['birthdate']), '%d/%m/%Y').year) < 18):
        return (jsonify({'message': 'Usuário menor de idade!'}), 400)
    elif ((str(data['gender']) != 'M') and (str(data['gender']) != 'F')):
        return (jsonify({'message': 'Gênero inválido!'}), 400)
    elif ((not str(data['phone']).isdigit()) or (len(str(data['phone'])) < 10)):
        return (jsonify({'message': 'Telefone inválido!'}), 400)
    elif (not validate_email(str(data['email']))):
        return (jsonify({'message': 'Email inválido!'}), 400)
    elif ((len(str(data['password'])) < 8) or (len(str(data['password'])) > 20)):
        return (jsonify({'message': 'Senha inválida!'}), 400)
    prospect_cpf = User.query.filter_by(cpf=data['cpf']).first()
    prospect_email = User.query.filter_by(email=data['email']).first()
    if prospect_cpf:
        return (jsonify({'message': 'CPF já cadastrado!'}), 400)
    elif prospect_email:
        return (jsonify({'message': 'Email já cadastrado!'}), 400)
    hashed_password = generate_password_hash(data['password'], method='sha256')
    new_user = User(public_id=str(uuid.uuid4()), name=data['name'], cpf=data['cpf'], birthdate=data['birthdate'], gender=data['gender'], phone=data['phone'], email=data['email'], password=hashed_password, passwordResetToken=None, passwordResetExpires=None)
    db.session.add(new_user)
    db.session.commit()
    return (jsonify({'message': 'Usuário cadastrado com sucesso!'}), 200)
@app.route('/users', methods=['POST'])
@cross_origin(supports_credentials=True)
def create_user():
    cpf = CPF()
    data = request.get_json()
    if ((not all(((x.isalpha() or x.isspace()) for x in str(data['name'])))) or (len(str(data['name'])) < 3) or (len(str(data['name'])) > 100)):
        return (jsonify({'message': 'Nome inválido!'}), 400)
    elif (not cpf.validate(str(data['cpf']))):
        return (jsonify({'message': 'CPF inválido!'}), 400)
    elif ((datetime.date.today().year - datetime.datetime.strptime(str(data['birthdate']), '%d/%m/%Y').year) < 18):
        return (jsonify({'message': 'Usuário menor de idade!'}), 400)
    elif ((str(data['gender']) != 'M') and (str(data['gender']) != 'F')):
        return (jsonify({'message': 'Gênero inválido!'}), 400)
    elif ((not str(data['phone']).isdigit()) or (len(str(data['phone'])) < 10)):
        return (jsonify({'message': 'Telefone inválido!'}), 400)
    elif (not validate_email(str(data['email']))):
        return (jsonify({'message': 'Email inválido!'}), 400)
    elif ((len(str(data['password'])) < 8) or (len(str(data['password'])) > 20)):
        return (jsonify({'message': 'Senha inválida!'}), 400)
    prospect_cpf = User.query.filter_by(cpf=data['cpf']).first()
    prospect_email = User.query.filter_by(email=data['email']).first()
    if prospect_cpf:
        return (jsonify({'message': 'CPF já cadastrado!'}), 400)
    elif prospect_email:
        return (jsonify({'message': 'Email já cadastrado!'}), 400)
    hashed_password = generate_password_hash(data['password'], method='sha256')
    new_user = User(public_id=str(uuid.uuid4()), name=data['name'], cpf=data['cpf'], birthdate=data['birthdate'], gender=data['gender'], phone=data['phone'], email=data['email'], password=hashed_password, passwordResetToken=None, passwordResetExpires=None)
    db.session.add(new_user)
    db.session.commit()
    return (jsonify({'message': 'Usuário cadastrado com sucesso!'}), 200)