@app.route('/login', methods=['POST'])
def login():
    data = request.get_json()
    if ('@' in data['nickOcorreo']):
        user = Usuario.query.filter_by(e_mail=data['nickOcorreo']).first()
    else:
        user = Usuario.query.filter_by(nick=data['nickOcorreo']).first()
    if (not user):
        return jsonify({'error': 'No existe ese usuario'})
    if (not check_password_hash(user.password, data['password'])):
        return jsonify({'error': 'Mal contraseña'})
    token = jwt.encode({'nick': data['nickOcorreo'], 'exp': (datetime.datetime.utcnow() + datetime.timedelta(minutes=9999999))}, app.config['SECRET_KEY'])
    return jsonify({'token': token.decode('UTF-8')})
@app.route('/login', methods=['POST'])
def login():
    data = request.get_json()
    if ('@' in data['nickOcorreo']):
        user = Usuario.query.filter_by(e_mail=data['nickOcorreo']).first()
    else:
        user = Usuario.query.filter_by(nick=data['nickOcorreo']).first()
    if (not user):
        return jsonify({'error': 'No existe ese usuario'})
    if (not check_password_hash(user.password, data['password'])):
        return jsonify({'error': 'Mal contraseña'})
    token = jwt.encode({'nick': data['nickOcorreo'], 'exp': (datetime.datetime.utcnow() + datetime.timedelta(minutes=9999999))}, app.config['SECRET_KEY'])
    return jsonify({'token': token.decode('UTF-8')})