예제 #1
0
파일: update.py 프로젝트: Caregivers/ckan
def user_generate_apikey(context, data_dict):
    '''Cycle a user's API key

    :param id: the name or id of the user whose key needs to be updated
    :type id: string

    :returns: the updated user
    :rtype: dictionary
    '''
    model = context['model']
    user = context['user']
    session = context['session']
    schema = context.get('schema') or schema_.default_generate_apikey_user_schema()
    context['schema'] = schema
    # check if user id in data_dict
    id = _get_or_bust(data_dict, 'id')

    # check if user exists
    user_obj = model.User.get(id)
    context['user_obj'] = user_obj
    if user_obj is None:
        raise NotFound('User was not found.')

    # check permission
    _check_access('user_generate_apikey', context, data_dict)

    # change key
    old_data = _get_action('user_show')(context, data_dict)
    old_data['apikey'] = model.types.make_uuid()
    data_dict = old_data
    return _get_action('user_update')(context, data_dict)
예제 #2
0
파일: update.py 프로젝트: wade1990/ckan
def user_generate_apikey(context, data_dict):
    '''Cycle a user's API key

    :param id: the name or id of the user whose key needs to be updated
    :type id: string

    :returns: the updated user
    :rtype: dictionary
    '''
    model = context['model']
    user = context['user']
    session = context['session']
    schema = context.get(
        'schema') or schema_.default_generate_apikey_user_schema()
    context['schema'] = schema
    # check if user id in data_dict
    id = _get_or_bust(data_dict, 'id')

    # check if user exists
    user_obj = model.User.get(id)
    context['user_obj'] = user_obj
    if user_obj is None:
        raise NotFound('User was not found.')

    # check permission
    _check_access('user_generate_apikey', context, data_dict)

    # change key
    old_data = _get_action('user_show')(context, data_dict)
    old_data['apikey'] = model.types.make_uuid()
    data_dict = old_data
    return _get_action('user_update')(context, data_dict)
예제 #3
0
파일: update.py 프로젝트: MrkGrgsn/ckan
def user_generate_apikey(context, data_dict):
    """Cycle a user's API key

    :param id: the name or id of the user whose key needs to be updated
    :type id: string

    :returns: the updated user
    :rtype: dictionary
    """
    model = context["model"]
    user = context["user"]
    session = context["session"]
    schema = context.get("schema") or schema_.default_generate_apikey_user_schema()
    context["schema"] = schema
    # check if user id in data_dict
    id = _get_or_bust(data_dict, "id")

    # check if user exists
    user_obj = model.User.get(id)
    context["user_obj"] = user_obj
    if user_obj is None:
        raise NotFound("User was not found.")

    # check permission
    _check_access("user_generate_apikey", context, data_dict)

    # change key
    old_data = _get_action("user_show")(context, data_dict)
    old_data["apikey"] = model.types.make_uuid()
    data_dict = old_data
    return _get_action("user_update")(context, data_dict)