diff --git a/cookbook/helper/permission_helper.py b/cookbook/helper/permission_helper.py index 4b104efe5..1ac842cd4 100644 --- a/cookbook/helper/permission_helper.py +++ b/cookbook/helper/permission_helper.py @@ -120,9 +120,12 @@ class GroupRequiredMixin(object): def dispatch(self, request, *args, **kwargs): if not has_group_permission(request.user, self.groups_required): - messages.add_message(request, messages.ERROR, _('You are not logged in and therefore cannot view this page!')) - return HttpResponseRedirect(reverse_lazy('account_login') + '?next=' + request.path) - + if not request.user.is_authenticated: + messages.add_message(request, messages.ERROR, _('You are not logged in and therefore cannot view this page!')) + return HttpResponseRedirect(reverse_lazy('account_login') + '?next=' + request.path) + else: + messages.add_message(request, messages.ERROR, _('You do not have the required permissions to view this page!')) + return HttpResponseRedirect(reverse_lazy('index')) try: obj = self.get_object() if obj.get_space() != request.space: