mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Merge pull request #20 from petterreinholdtsen/expert-user-access
Fix expert user access checks.
This commit is contained in:
commit
4c42c1ad1f
@ -19,7 +19,21 @@ class UserStore(UserStoreModule, sqlite_db):
|
|||||||
def close(self):
|
def close(self):
|
||||||
self.__exit__(None,None,None)
|
self.__exit__(None,None,None)
|
||||||
|
|
||||||
|
def current(self, name=False):
|
||||||
|
"""Return current user, if there is one, else None.
|
||||||
|
If name = True, return the username instead of the user."""
|
||||||
|
try:
|
||||||
|
username = cherrypy.session.get(cfg.session_key)
|
||||||
|
if name:
|
||||||
|
return username
|
||||||
|
else:
|
||||||
|
return self.get(username)
|
||||||
|
except AttributeError:
|
||||||
|
return None
|
||||||
|
|
||||||
def expert(self, username=None):
|
def expert(self, username=None):
|
||||||
|
if not username:
|
||||||
|
username = self.current(name=True)
|
||||||
groups = self.attr(username,"groups")
|
groups = self.attr(username,"groups")
|
||||||
if not groups:
|
if not groups:
|
||||||
return False
|
return False
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user