mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
fix: account API output^ (#874)
This commit is contained in:
parent
3cd98251b3
commit
8f6a800836
@ -761,12 +761,20 @@ def api_list_accounts(account_name):
|
|||||||
Account.name == account_name).all()
|
Account.name == account_name).all()
|
||||||
if not account_list:
|
if not account_list:
|
||||||
abort(404)
|
abort(404)
|
||||||
return jsonify(account_schema.dump(account_list)), 200
|
if account_name is None:
|
||||||
|
return jsonify(account_schema.dump(account_list)), 200
|
||||||
|
else:
|
||||||
|
return jsonify(account_schema.dump(account_list)[0]), 200
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route('/pdnsadmin/accounts', methods=['POST'])
|
@api_bp.route('/pdnsadmin/accounts', methods=['POST'])
|
||||||
@api_basic_auth
|
@api_basic_auth
|
||||||
def api_create_account():
|
def api_create_account():
|
||||||
|
account_exists = [] or Account.query.filter(Account.name == account_name).all()
|
||||||
|
if len(account_exists) > 0:
|
||||||
|
msg = "Account name already exists"
|
||||||
|
current_app.logger.debug(msg)
|
||||||
|
raise AccountCreateFail(message=msg)
|
||||||
if current_user.role.name not in ['Administrator', 'Operator']:
|
if current_user.role.name not in ['Administrator', 'Operator']:
|
||||||
msg = "{} role cannot create accounts".format(current_user.role.name)
|
msg = "{} role cannot create accounts".format(current_user.role.name)
|
||||||
raise NotEnoughPrivileges(message=msg)
|
raise NotEnoughPrivileges(message=msg)
|
||||||
@ -795,7 +803,7 @@ def api_create_account():
|
|||||||
history = History(msg='Create account {0}'.format(account.name),
|
history = History(msg='Create account {0}'.format(account.name),
|
||||||
created_by=current_user.username)
|
created_by=current_user.username)
|
||||||
history.add()
|
history.add()
|
||||||
return jsonify(account_schema.dump([account])), 201
|
return jsonify(account_schema.dump([account])[0]), 201
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route('/pdnsadmin/accounts/<int:account_id>', methods=['PUT'])
|
@api_bp.route('/pdnsadmin/accounts/<int:account_id>', methods=['PUT'])
|
||||||
|
Loading…
Reference in New Issue
Block a user