mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 14:40:27 +00:00
commit
a1619cfde9
@ -60,31 +60,31 @@ class ApiKey(db.Model):
|
|||||||
|
|
||||||
def update(self, role_name=None, description=None, domains=None, accounts=None):
|
def update(self, role_name=None, description=None, domains=None, accounts=None):
|
||||||
try:
|
try:
|
||||||
if role_name:
|
if role_name:
|
||||||
role = Role.query.filter(Role.name == role_name).first()
|
role = Role.query.filter(Role.name == role_name).first()
|
||||||
self.role_id = role.id
|
self.role_id = role.id
|
||||||
|
|
||||||
if description:
|
if description:
|
||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
if domains is not None:
|
if domains is not None:
|
||||||
domain_object_list = Domain.query \
|
domain_object_list = Domain.query \
|
||||||
.filter(Domain.name.in_(domains)) \
|
.filter(Domain.name.in_(domains)) \
|
||||||
.all()
|
.all()
|
||||||
self.domains[:] = domain_object_list
|
self.domains[:] = domain_object_list
|
||||||
|
|
||||||
if accounts is not None:
|
if accounts is not None:
|
||||||
account_object_list = Account.query \
|
account_object_list = Account.query \
|
||||||
.filter(Account.name.in_(accounts)) \
|
.filter(Account.name.in_(accounts)) \
|
||||||
.all()
|
.all()
|
||||||
self.accounts[:] = account_object_list
|
self.accounts[:] = account_object_list
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg_str = 'Update of apikey failed. Error: {0}'
|
msg_str = 'Update of apikey failed. Error: {0}'
|
||||||
current_app.logger.error(msg_str.format(e))
|
current_app.logger.error(msg_str.format(e))
|
||||||
db.session.rollback
|
db.session.rollback() # fixed line
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def get_hashed_password(self, plain_text_password=None):
|
def get_hashed_password(self, plain_text_password=None):
|
||||||
# Hash a password for the first time
|
# Hash a password for the first time
|
||||||
|
Loading…
Reference in New Issue
Block a user