mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 12:37:16 +02:00
Adding the first bit of permissions checking as an example. See cmd_who and the Object class's user_has_perm method for examples. We'll need to start fleshing this stuff out before adding many more new commands. For existing games, remove your auth_permissions table and re-sync your DB.
This commit is contained in:
parent
f1dd985294
commit
2fc06adcfa
3 changed files with 51 additions and 17 deletions
|
|
@ -129,6 +129,22 @@ class Object(models.Model):
|
|||
else:
|
||||
return profile[0].is_superuser
|
||||
|
||||
def user_has_perm(self, perm):
|
||||
"""
|
||||
Checks to see whether a user has the specified permission or is a super
|
||||
user.
|
||||
"""
|
||||
if not self.is_player():
|
||||
return False
|
||||
|
||||
if self.is_superuser():
|
||||
return True
|
||||
|
||||
if self.get_user_account().has_perm(perm):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def owns_other(self, other_obj):
|
||||
"""
|
||||
See if the envoked object owns another object.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue