]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/lib/permissions.py
Don't let non-residents create new users.
[bluechips.git] / bluechips / lib / permissions.py
index 75429eae20d9024dd973a3a5598fa7d1caab40f7..2249726b8a554e264e79632e4b03654f130625ef 100644 (file)
@@ -20,6 +20,16 @@ class BlueChipUser(RequestPermission):
             raise NotAuthorizedError('You are not allowed access.') # pragma: nocover
         return app(environ, start_response)
 
+class BlueChipResident(RequestPermission):
+    def check(self, app, environ, start_response):
+        if 'user' not in environ:
+            raise NotAuthenticatedError('Not Authenticated')
+
+        if not getattr(environ['user'], 'resident', False):
+            raise NotAuthorizedError('You are not allowed access.')
+
+        return app(environ, start_response)
+
 class DummyAuthenticate(AddDictToEnviron):
     """
     Set the authkit.authenticate environment variable so