Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom redirect for django-allauth social login cancel

I am using django-allauth for social login in my django application. When a user is prompted with a social-login dialog, Facebook login window for ex., he can choose to decline the request for permissions.

In this case, the user is currently getting redirected to /accounts/social/login/cancelled/. Is there some way by which I can redirect him to a custom url?

like image 954
Siddardha G Avatar asked Mar 19 '23 12:03

Siddardha G


1 Answers

I figured out that I can override allauth's social login cancel view with my custom view. I followed the instructions described in this blog post - How to override a view from an external Django app.

All I needed to do was define a view with my custom logic and place a url definition for this view above the allauth urls definition in urls.py

views.py:

def login_cancelled(request):
    ...
    custom_logic
    ...

urls.py

from myapp.views import login_cancelled

urlpattenrs = patterns(
    ...
    url(r'^accounts/social/login/cancelled/$', login_cancelled),
    url(r'^accounts/', include('allauth.urls')),
    ...
)
like image 104
Siddardha G Avatar answered Apr 02 '23 11:04

Siddardha G