python - Run javascript on django login and logout events -
is possible execute javascript (in template) after successful login event or after successful logout event. if yes, how?
i don't want asscociate login button click or logout button click on js level because
- clicking button not guarantee successful login/logout event
- i have lot of login , logout buttons, many templates , partials looking centralized solution
by way using python-social-auth.
here's how i'd approach it.
make view has template contains js want execute on login (it blank page redirects somewhere else, or template extends template... there myriad of ways dry here, think).
set
social_auth_login_redirect_url
,social_auth_new_user_redirect_url
, and/orsocial_auth_new_association_redirect_url
(whichever of decide use in step 3) insettings.py
.make entry in
urls.py
makes view accessible eithersocial_auth_login_redirect_url
(or bothsocial_auth_new_user_redirect_url
,social_auth_new_association_redirect_url
, if want execute new users of site).
i'm getting settings variables django-social-auth docs.
Comments
Post a Comment