mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 19:57:29 +01:00
Add permission validation to Package.checkPerm()
This commit is contained in:
parent
bd58f9bee9
commit
73f24add61
@ -141,6 +141,8 @@ class Package(db.Model):
|
|||||||
|
|
||||||
if type(perm) == str:
|
if type(perm) == str:
|
||||||
perm = Permission[perm]
|
perm = Permission[perm]
|
||||||
|
elif type(perm) != Permission:
|
||||||
|
raise Exception("Unknown permission given to Package.checkPerm()")
|
||||||
|
|
||||||
isOwner = user == self.author
|
isOwner = user == self.author
|
||||||
|
|
||||||
@ -158,7 +160,7 @@ class Package(db.Model):
|
|||||||
return user.rank.atLeast(UserRank.MODERATOR)
|
return user.rank.atLeast(UserRank.MODERATOR)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return False
|
raise Exception("Permission {} is not related to packages".format(perm.name))
|
||||||
|
|
||||||
# Setup Flask-User
|
# Setup Flask-User
|
||||||
db_adapter = SQLAlchemyAdapter(db, User) # Register the User model
|
db_adapter = SQLAlchemyAdapter(db, User) # Register the User model
|
||||||
|
Loading…
Reference in New Issue
Block a user