django login url with param

53 views Asked by At

a third party authentication requires api must to be called in the index view. for example, my domain is zzd.com, then they only provide api to zzd.com, which means we cannot have route specified for a signin view, which unable to put all login stuff into zzd.com/login/

however, index view is designed to shows some other important info primarily rather than login QR. hence we use a login button, when user click, switch the content to login QR.

here's the issue, I have following declaration in settings.py:

the index view serves all stuff in one template, including trending info, and login qr code if user is not authed. js looks like this:

const url = new window.URL(window.location.href);
let mode = url.searchParams.get('mode');
if(mode === 'login'){
    showLoginQrCodeScanner();
}

which login qr img would only show if index/?mode=login specified, otherwise would display trending info instead. and my settings.py:

LOGIN_REDIRECT_URL = 'index'
LOGIN_URL = 'index'

the issue is that, I have some of my views @login_required, but, an anonymous user, would get redirected to the index/?next=particular/url, without the mode=login part, which does not show the qr in default.

is there a way to declare login url with the param, for a much better user experience?

0

There are 0 answers