def post(username, database_id): """ Add user information with specified username. Args: user (string): The first parameter. Returns: Deployment user object of added deployment user. """ inputs = UserInputs(request) if not inputs.validate(): return jsonify(success=False, errors=inputs.errors) current_user = [user for user in DEPLOYMENT_USERS if user['name'] == username and user['databaseid'] == database_id] current_user[0]['name'] = request.json.get('name', current_user[0]['name']) current_user[0]['password'] = request.json.get('password', current_user[0]['password']) current_user[0]['roles'] = request.json.get('roles', current_user[0]['roles']) current_user[0]['plaintext'] = request.json.get('plaintext', current_user[0]['plaintext']) return jsonify({'user': current_user[0], 'status': 1, 'statusstring': "User Updated"})
def put(username, database_id): """ Add user information with specified username. Args: user (string): The first parameter. Returns: Deployment user object of added deployment user. """ inputs = UserInputs(request) if not inputs.validate(): return jsonify(success=False, errors=inputs.errors) current_user = [user for user in DEPLOYMENT_USERS if user['name'] == username and user['databaseid'] == database_id] if len(current_user) != 0: return make_response(jsonify({'error': 'Duplicate Username' , 'success': False}), 404) deployment_user = map_deployment_users(request, username) return jsonify({'user': deployment_user, 'status': 1, 'statusstring': 'User Created'})