Skip to content

Abstract out login and logout views #3

@vergeev

Description

@vergeev

Basically we want to do exactly what django.contrib.auth did with their urls.

This is how the user would create login and logout views with the current version:

url(r'^login/$', views.CustomSocialLoginView.as_view(), name='login'),
url(r'^logout/$', partial(auth_views.logout, template_name='logout.html'), name='logout'),

Instead we them to simply go

url(r'', include('django_social_pill.urls'), namespace='social_pill'),

To achieve this, we have to make the following view more generic:

class CustomSocialLoginView(TemplateView):
    template_name = 'login.html'

    def get(self, request, *args, **kwargs):
        if request.user.is_authenticated():
            return redirect('users:profile')
        return super().get(request, *args, **kwargs)

so that we could replace the template and the redirect url with an arbitrary one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions