x
x
stored inside the JS specific to the third party page window.open("http://localhost:8000/accounts/facebook/login/?method=oauth2", "AskAFriend Facebook Login","menubar=0,toolbar=0;scrollbars=0;dialog=0;resizable=1,width=480px,height=320px");
the code above opens a new window for the facebook login process, which when completed redirects to a view i have designed in my django app, i have achieved this by providing the url to this view in the LOGIN_REDIRECT_URL
setting in settings.py
now i need a way to add a parameter to this request which can reach my view after the login completes, how can i achieve this?
i have tried adding it to the url i used in my JS like window.open("http://localhost:8000/accounts/facebook/login/?method=oauth2&*valueofx=' + x* ...
(did not work)(ignore the *)
I have read about overriding the get_login_redirect_url()
function by using a custom adapter but i can't figure out how to do it for my specific case
You could change LOGIN_REDIRECT_URL
to something like /redirect
and this will in turn be an 'intermediary' view that controls where the user gets redirected to.
That view could look something like this (untested):
from django.views.generic import View
from django.http import HttpResponseRedirect
class LoginRedirectIntermediary(View):
"""
Decides where a newly logged in user should go based on the request.
"""
def get(self, request, *args, **kwargs):
if request.user.is_superuser:
url = '/admin-panel/{}/'
else:
url = '/user-panel/{}/'
return HttpResponseRedirect(url.format(request.user.username))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.