level12 / keg-auth

Robust authentication system for Keg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Login/Logout navigation should only show when relevant

rsyring opened this issue · comments

            NavItem(
                'Auth',
                NavItem('Login', NavURL('auth.login')),
                NavItem('Logout', NavURL('auth.logout')),
                NavItem('Bundles', NavURL('auth.bundle:list')),
                NavItem('Groups', NavURL('auth.group:list')),
                NavItem('Users', NavURL('auth.user:list')),
            ),

Unless I'm missing something, assuming the above, Login and Logout links show in the navigation always and it's not easy to set them setup so logout only shows when the use is authenticated and login when unauthenticated. Maybe something like:

            NavItem(
                'Auth',
                NavItem('Login', NavURL('auth.login'), when='anonymous'),
                NavItem('Logout', NavURL('auth.logout'), when='authenticated'),
                NavItem('Bundles', NavURL('auth.bundle:list')),
                NavItem('Groups', NavURL('auth.group:list')),
                NavItem('Users', NavURL('auth.user:list')),
            ),

Handled the logout case on the view - in general, requires_user and requires_permissions should be sufficient for that sort of thing.

But we didn't have a way to designate routes as public-only. Added a NavURL kwarg "requires_anonymous" to match the requires_permissions nomenclature.