mirror of
https://github.com/laurivosandi/certidude
synced 2024-12-23 00:25:18 +00:00
Fix is_admin of PosixUserManager
This commit is contained in:
parent
de42d97b59
commit
22846327a0
@ -26,6 +26,7 @@ class User(object):
|
|||||||
return hash(self.mail)
|
return hash(self.mail)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
assert isinstance(other, User), "%s is not instance of User" % repr(other)
|
||||||
return self.mail == other.mail
|
return self.mail == other.mail
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -56,10 +57,10 @@ class PosixUserManager(object):
|
|||||||
for username in members:
|
for username in members:
|
||||||
yield self.get(username)
|
yield self.get(username)
|
||||||
|
|
||||||
def is_admin(self, username):
|
def is_admin(self, user):
|
||||||
import grp
|
import grp
|
||||||
_, _, gid, members = grp.getgrnam(config.ADMIN_GROUP)
|
_, _, gid, members = grp.getgrnam(config.ADMIN_GROUP)
|
||||||
return username in members
|
return user.name in members
|
||||||
|
|
||||||
|
|
||||||
class DirectoryConnection(object):
|
class DirectoryConnection(object):
|
||||||
@ -161,5 +162,5 @@ if config.ACCOUNTS_BACKEND == "ldap":
|
|||||||
elif config.ACCOUNTS_BACKEND == "posix":
|
elif config.ACCOUNTS_BACKEND == "posix":
|
||||||
User.objects = PosixUserManager()
|
User.objects = PosixUserManager()
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Authorization backend %s not supported" % config.AUTHORIZATION_BACKEND)
|
raise NotImplementedError("Authorization backend %s not supported" % repr(config.AUTHORIZATION_BACKEND))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user