optimized domain permission check for normal users

This commit is contained in:
thomasDOTde 2017-12-04 22:18:28 +01:00
parent 47cf1aff4a
commit 049a8a4547

View File

@ -366,11 +366,10 @@ class User(db.Model):
if self.role.name == "Administrator":
return True
query = db.session.query(User, DomainUser, Domain).filter(User.id==self.id).filter(User.id==DomainUser.user_id).filter(Domain.id==DomainUser.domain_id).all()
for q in query:
if q[2].name == domain_name:
return True
return False
query = db.session.query(User, DomainUser, Domain).filter(User.id == self.id).filter(
User.id == DomainUser.user_id).filter(Domain.id == DomainUser.domain_id).filter(
Domain.name == domain_name)
return query.count() >= 1
def delete(self):
"""