From 22846327a0598bb7a6120edb8391aca0f5373212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Tue, 29 Mar 2016 08:44:07 +0300 Subject: [PATCH] Fix is_admin of PosixUserManager --- certidude/user.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/certidude/user.py b/certidude/user.py index ae24d80..722b189 100644 --- a/certidude/user.py +++ b/certidude/user.py @@ -26,6 +26,7 @@ class User(object): return hash(self.mail) def __eq__(self, other): + assert isinstance(other, User), "%s is not instance of User" % repr(other) return self.mail == other.mail def __repr__(self): @@ -56,10 +57,10 @@ class PosixUserManager(object): for username in members: yield self.get(username) - def is_admin(self, username): + def is_admin(self, user): import grp _, _, gid, members = grp.getgrnam(config.ADMIN_GROUP) - return username in members + return user.name in members class DirectoryConnection(object): @@ -161,5 +162,5 @@ if config.ACCOUNTS_BACKEND == "ldap": elif config.ACCOUNTS_BACKEND == "posix": User.objects = PosixUserManager() else: - raise NotImplementedError("Authorization backend %s not supported" % config.AUTHORIZATION_BACKEND) + raise NotImplementedError("Authorization backend %s not supported" % repr(config.AUTHORIZATION_BACKEND))