Presently library's documentations provides examples only for using it with Django's function based views. It would be helpful to provide examples for using it with class based views, as finding correct way without documentation was somewhat tedious.
As an example, following can be used:
`
View classes
class index(TemplateView):
"""
Creates index view. It is the "home page".
"""
template_name = "index.html"
@method_decorator(settings.AUTH.login_required)
def dispatch(self, request, *args, context, **kwargs):
return super().dispatch(request, *args, **kwargs)
def get(self, *args, **kwargs):
"""
Handle GET requests to display the index page.
Args:
*args: Positional arguments.
**kwargs: Keyword arguments.
Returns:
HttpResponse: The rendered index page.
"""
<code for rendering index page>
`
Further on, using a class based view in post_logout_view at library's config requires slightly different definition:
AUTH = Auth( client_id=os.getenv('ENTRA_CLIENT_ID'), client_credential=os.getenv('ENTRA_CLIENT_SECRET'), redirect_uri=os.getenv('REDIRECT_URI'), authority=os.getenv('AUTHORITY'), post_logout_view='loggedout' )
I.e. you have to use name defined for the URL instead of name of the function.
Presently library's documentations provides examples only for using it with Django's function based views. It would be helpful to provide examples for using it with class based views, as finding correct way without documentation was somewhat tedious.
As an example, following can be used:
`
View classes
class index(TemplateView):
"""
Creates index view. It is the "home page".
"""
template_name = "index.html"
`
Further on, using a class based view in post_logout_view at library's config requires slightly different definition:
AUTH = Auth( client_id=os.getenv('ENTRA_CLIENT_ID'), client_credential=os.getenv('ENTRA_CLIENT_SECRET'), redirect_uri=os.getenv('REDIRECT_URI'), authority=os.getenv('AUTHORITY'), post_logout_view='loggedout' )I.e. you have to use name defined for the URL instead of name of the function.