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"}
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', }
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'}
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 ], }
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"}
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 ] }