Implemented role-based access control, Updated e2e authentication tests and Playwright setup.
This commit is contained in:
@@ -6,9 +6,10 @@ class BaseComponent:
|
||||
Base class for all components that need to have a session and an id
|
||||
"""
|
||||
|
||||
def __init__(self, session, _id=None, **kwargs):
|
||||
def __init__(self, session, _id=None, role_name=None, **kwargs):
|
||||
self._session = session
|
||||
self._id = _id or self.create_component_id(session)
|
||||
self._role_name = role_name
|
||||
|
||||
def get_id(self):
|
||||
return self._id
|
||||
@@ -34,6 +35,17 @@ class BaseComponent:
|
||||
@staticmethod
|
||||
def create_component_id(session):
|
||||
pass
|
||||
|
||||
def render(self):
|
||||
pass
|
||||
|
||||
def __ft__(self):
|
||||
if (not self._session["is_admin"] and
|
||||
self._role_name is not None and
|
||||
self._role_name not in self._session["roles"]):
|
||||
return None
|
||||
|
||||
return self.render()
|
||||
|
||||
|
||||
class BaseComponentSingleton(BaseComponent):
|
||||
@@ -43,8 +55,8 @@ class BaseComponentSingleton(BaseComponent):
|
||||
|
||||
COMPONENT_INSTANCE_ID = None
|
||||
|
||||
def __init__(self, session, _id=None, settings_manager=None, tabs_manager=None, **kwargs):
|
||||
super().__init__(session, _id, **kwargs)
|
||||
def __init__(self, session, _id=None, role_name=None, settings_manager=None, tabs_manager=None, **kwargs):
|
||||
super().__init__(session, _id, role_name,**kwargs)
|
||||
self._settings_manager = settings_manager
|
||||
self.tabs_manager = tabs_manager
|
||||
|
||||
|
||||
Reference in New Issue
Block a user