diff --git a/ordr/resources/__init__.py b/ordr/resources/__init__.py index be6927b..90222b5 100644 --- a/ordr/resources/__init__.py +++ b/ordr/resources/__init__.py @@ -2,11 +2,7 @@ from pyramid.security import Allow, Everyone, DENY_ALL -from .account import ( - RegistrationResource, - PasswordResetResource, - AccountResource - ) +from .account import AccountResource class RootResource: @@ -14,12 +10,12 @@ class RootResource: :param pyramid.request.Request request: the current request object ''' - + nav_active = 'welcome' def __init__(self, request): ''' Create the root resource - + :param pyramid.request.Request request: the current request object ''' self.__name__ = None @@ -29,17 +25,15 @@ class RootResource: def __acl__(self): ''' access controll list for the resource ''' return [(Allow, Everyone, 'view'), DENY_ALL] - + def __getitem__(self, key): ''' retruns a child resource - + :param str key: name of the child resource :returns: child resource :raises: KeyError if child resource is not found ''' map = { - 'register': RegistrationResource, - 'forgot': PasswordResetResource, 'account': AccountResource, } child_class = map[key] diff --git a/ordr/resources/account.py b/ordr/resources/account.py index a7689e5..890157d 100644 --- a/ordr/resources/account.py +++ b/ordr/resources/account.py @@ -28,7 +28,7 @@ class RegistrationTokenResource(BaseChildResource): def __acl__(self): ''' access controll list for the resource ''' - return [(Allow, Everyone, 'view'), DENY_ALL] + return [(Allow, Everyone, 'register'), DENY_ALL] class RegistrationResource(BaseChildResource): @@ -43,7 +43,7 @@ class RegistrationResource(BaseChildResource): def __acl__(self): ''' access controll list for the resource ''' - return [(Allow, Everyone, 'view'), DENY_ALL] + return [(Allow, Everyone, 'register'), DENY_ALL] def __getitem__(self, key): ''' returns a resource for a valid registration token ''' @@ -81,7 +81,7 @@ class PasswordResetTokenResource(BaseChildResource): def __acl__(self): ''' access controll list for the resource ''' - return [(Allow, Everyone, 'view'), DENY_ALL] + return [(Allow, Everyone, 'reset'), DENY_ALL] def get_reset_form(self, **kwargs): ''' returns password reset form ''' @@ -107,7 +107,7 @@ class PasswordResetResource(BaseChildResource): def __acl__(self): ''' access controll list for the resource ''' - return [(Allow, Everyone, 'view'), DENY_ALL] + return [(Allow, Everyone, 'reset'), DENY_ALL] def __getitem__(self, key): ''' returns a resource for a valid reset password token ''' @@ -156,10 +156,28 @@ class AccountResource(BaseChildResource): def __acl__(self): ''' access controll list for the resource ''' - return [(Allow, Authenticated, 'edit'), DENY_ALL] + return [ + (Allow, Everyone, 'view'), + (Allow, Everyone, 'login'), + (Allow, Everyone, 'logout'), + (Allow, Everyone, 'register'), + (Allow, Everyone, 'reset'), + (Allow, Authenticated, 'edit'), + DENY_ALL + ] def __getitem__(self, key): - ''' returns a resource for a valid change email token ''' + ''' returns a resource for child resource ''' + # static child resources + map = { + 'register': RegistrationResource, + 'forgot': PasswordResetResource, + } + if key in map: + child_class = map[key] + return child_class(name=key, parent=self) + + # change email verification token = Token.retrieve(self.request, key, TokenSubject.CHANGE_EMAIL) if token is None: raise KeyError(f'Token {key} not found') diff --git a/ordr/templates/pages/login.jinja2 b/ordr/templates/account/login.jinja2 similarity index 95% rename from ordr/templates/pages/login.jinja2 rename to ordr/templates/account/login.jinja2 index 5513381..bdfa0ad 100644 --- a/ordr/templates/pages/login.jinja2 +++ b/ordr/templates/account/login.jinja2 @@ -12,7 +12,7 @@