示例#1
0
文件: views.py 项目: bdyetton/osf.io
def create_user_key(**kwargs):

    # Generate key
    api_key = ApiKey(label=request.form["label"])
    api_key.save()

    # Append to user
    user = kwargs["auth"].user
    user.api_keys.append(api_key)
    user.save()

    # Return response
    return {"response": "success"}
示例#2
0
def create_user_key(**kwargs):

    # Generate key
    api_key = ApiKey(label=request.form['label'])
    api_key.save()

    # Append to user
    user = kwargs['auth'].user
    user.api_keys.append(api_key)
    user.save()

    # Return response
    return {
        'response': 'success',
    }
示例#3
0
文件: views.py 项目: Doris1989/osf.io
def create_user_key(**kwargs):

    # Generate key
    api_key = ApiKey(label=request.form['label'])
    api_key.save()

    # Append to user
    user = kwargs['auth'].user
    user.api_keys.append(api_key)
    user.save()

    # Return response
    return {
        'response': 'success',
    }
示例#4
0
def revoke_user_key(**kwargs):

    # Load key
    api_key = ApiKey.load(request.form['key'])

    # Remove from user
    user = kwargs['auth'].user
    user.api_keys.remove(api_key)
    user.save()

    # Return response
    return {'response': 'success'}
示例#5
0
文件: views.py 项目: Doris1989/osf.io
def revoke_user_key(**kwargs):

    # Load key
    api_key = ApiKey.load(request.form['key'])

    # Remove from user
    user = kwargs['auth'].user
    user.api_keys.remove(api_key)
    user.save()

    # Return response
    return {'response': 'success'}
示例#6
0
文件: views.py 项目: bdyetton/osf.io
def user_key_history(**kwargs):

    api_key = ApiKey.load(kwargs["kid"])
    return {
        "key": api_key._id,
        "label": api_key.label,
        "route": "/settings",
        "logs": [
            {"lid": log._id, "nid": log.node__logged[0]._id, "route": log.node__logged[0].url}
            for log in api_key.nodelog__created
        ],
    }
示例#7
0
文件: views.py 项目: bdyetton/osf.io
def revoke_user_key(**kwargs):

    # Load key
    api_key = ApiKey.load(request.form["key"])

    # Remove from user
    user = kwargs["auth"].user
    user.api_keys.remove(api_key)
    user.save()

    # Return response
    return {"response": "success"}
示例#8
0
def user_key_history(**kwargs):

    api_key = ApiKey.load(kwargs['kid'])
    return {
        'key': api_key._id,
        'label': api_key.label,
        'route': '/settings',
        'logs': [
            {
                'lid': log._id,
                'nid': log.node__logged[0]._id,
                'route': log.node__logged[0].url,
            }
            for log in api_key.nodelog__created
        ]
    }
示例#9
0
文件: views.py 项目: Doris1989/osf.io
def user_key_history(**kwargs):

    api_key = ApiKey.load(kwargs['kid'])
    return {
        'key': api_key._id,
        'label': api_key.label,
        'route': '/settings',
        'logs': [
            {
                'lid': log._id,
                'nid': log.node__logged[0]._id,
                'route': log.node__logged[0].url,
            }
            for log in api_key.nodelog__created
        ]
    }