From 2c18e5c88fec60418a3b961a41cc835c742221d6 Mon Sep 17 00:00:00 2001 From: jbe-dw <50663045+jbe-dw@users.noreply.github.com> Date: Thu, 7 Jan 2021 23:07:20 +0100 Subject: [PATCH] fix: User role was not assigned upon creation (#860) --- powerdnsadmin/models/user.py | 3 ++- powerdnsadmin/routes/api.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/powerdnsadmin/models/user.py b/powerdnsadmin/models/user.py index a3f31cd..f2adc8d 100644 --- a/powerdnsadmin/models/user.py +++ b/powerdnsadmin/models/user.py @@ -431,7 +431,8 @@ class User(db.Model): return {'status': False, 'msg': 'Email address is already in use'} # first register user will be in Administrator role - self.role_id = Role.query.filter_by(name='User').first().id + if self.role_id is None: + self.role_id = Role.query.filter_by(name='User').first().id if User.query.count() == 0: self.role_id = Role.query.filter_by( name='Administrator').first().id diff --git a/powerdnsadmin/routes/api.py b/powerdnsadmin/routes/api.py index 300dc59..79ba125 100644 --- a/powerdnsadmin/routes/api.py +++ b/powerdnsadmin/routes/api.py @@ -845,7 +845,7 @@ def api_add_account_user(account_id, user_id): user.username, account.name)) history = History( - msg='Revoke {} user privileges on {}'.format( + msg='Add {} user privileges on {}'.format( user.username, account.name), created_by=current_user.username) history.add()