Ejemplo n.º 1
0
def create_user():
    user_to_create, errors = create_user_schema.load(request.get_json())
    req_json = request.get_json()
    if not req_json.get('password', None):
        errors.update({'password': ['Missing data for required field.']})
        raise InvalidRequest(errors, status_code=400)
    save_model_user(user_to_create, pwd=req_json.get('password'))
    result = user_to_create.serialize()
    return jsonify(data=result), 201
Ejemplo n.º 2
0
def create_user():
    # import pdb; pdb.set_trace()
    user_to_create, errors = create_user_schema.load(request.get_json())
    req_json = request.get_json()

    password = req_json.get('password', None)
    if not password:
        errors.update({'password': ['Missing data for required field.']})
        raise InvalidRequest(errors, status_code=400)
    else:
        response = pwnedpasswords.check(password)
        if response > 0:
            errors.update({'password': ['Password is not allowed.']})
            raise InvalidRequest(errors, status_code=400)

    save_model_user(user_to_create, pwd=req_json.get('password'))
    result = user_to_create.serialize()
    return jsonify(data=result), 201
def create_user():
    user_to_create, errors = create_user_schema.load(request.get_json())
    req_json = request.get_json()

    identity_provider_user_id = req_json.get('identity_provider_user_id', None)
    password = req_json.get('password', None)

    if not password and not identity_provider_user_id:
        errors.update({'password': ['Missing data for required field.']})
        raise InvalidRequest(errors, status_code=400)
    elif password:
        response = pwnedpasswords.check(password)
        if response > 0:
            errors.update({'password': ['Password is blacklisted.']})
            raise InvalidRequest(errors, status_code=400)

    save_model_user(user_to_create, pwd=req_json.get('password'))
    result = user_to_create.serialize()
    return jsonify(data=result), 201