Skip to main content

How would I ensure that only authorised users are able to access this class based view

I have a risk entry view that only project managers are able to access and no other user group how would I ensure that only this user group is able to access this view?

Risk page class-based view

@method_decorator(decorators, name='dispatch')
class Risk_entry_page(View):

    template_name = 'risk/riskEntry.html'

    def get(self, request, *args, **kwargds):
        return render(request, self.template_name)

Risk Urls

urlpatterns = [
    path('', views.Solution_area_home_page.as_view(), name='risks-home-page'),
    path('risk/', views.Risk_entry_page.as_view(), name='risk-entry-page'),
    path('assumption/', views.Assumption_entry_page.as_view(), name='assumption-entry-page'),
    path('issue/', views.Issue_entry_page.as_view(), name='issue-entry-page'),
    path('dependency/', views.Dependency_entry_page.as_view(), name='dependency-entry-page'),
    path('logout/', views.Logout.as_view(), name='logout-view'),
]


source https://stackoverflow.com/questions/74415265/how-would-i-ensure-that-only-authorised-users-are-able-to-access-this-class-base

Comments