viewflow / django-material

Material Design for Django
http://viewflow.io/
BSD 3-Clause "New" or "Revised" License
2.49k stars 425 forks source link

LoginRequiredMixin has not effect on material.frontend.views #484

Closed fretscha closed 4 years ago

fretscha commented 4 years ago

For class based views in material.frontend.views I would like to redirect to the login_url if the user is not authenticated (anonymous). LoginRequiredMixin should help us here, correct?

from django.contrib.auth.mixins import LoginRequiredMixin
from material.frontend.views import ModelViewSet
from . import models

class MyModelViewSet(LoginRequiredMixin, ModelViewSet):
    model = models.MyModel

All objects in MyModel need permissions. Anonymous users get no permissions

When I request the detail view of the ViewSet as an anonymous user, the 403 Page is shown. Since the the user is not authenticated we get from detail.get_object a PermissionDenied.

Instead we'd expect/want a redirection to the login_url.

Any clue what is going wrong here!

fretscha commented 4 years ago

Broken AUTHENTICATION_BACKEND was causing the problem.