Page 1 of 1

get to specified page after login

Posted: 2020-07-03 19:58
by pbottcher
Hi,

sometimes it is uesful to provide a link to a specific record, but when clicking on the record, you app is asking for login authentication and redirects afterwards to the index page.

To bypass this behaviour you can try this code. Add it to the hooks/header-extras.php.

Code: Select all

<script>
var ref=window.location.href;
if (ref.includes('index.php') == 0 && $j('.navbar-text').not('.navbar-right').length == 0) {
                localStorage.setItem('redirecturl', ref);
}
else {
                if ($j('.navbar-text').length != 0 && ref.includes('index.php') != 0 && localStorage.hasOwnProperty("redirecturl")) {
                               ref=localStorage.getItem('redirecturl');
                               localStorage.removeItem('redirecturl');
                               $j(location).attr('href', ref);
                }
}
 </script>

Re: get to specified page after login

Posted: 2020-07-14 21:18
by aarlauskas
Wasnt doing much work due to covid recently, but cant wait to try your code. If it works, then you are genius! :D
I have highlighted this issue before but didnt get any response. Will let you know. Thanks!

Re: get to specified page after login

Posted: 2020-07-15 18:00
by nycwebmaster
It Works! Thanks! BTW I will send you an email.

Re: get to specified page after login

Posted: 2021-01-17 20:21
by aarlauskas
Many thanks for this Pascal! This works very well. How do you pass the address of the actual record? I can only navigate to a table, but if I click on the record in that table, the address in the browser doesnt change, still displays the address of the table. Is this something can be enabled so I can give the link to the record?

Re: get to specified page after login

Posted: 2021-02-10 15:38
by pbottcher
Here a new version for 5.94

Code: Select all

<script>
// script to handle direct access to page after login. Set sessionStorage to remeber page and redirect to that page after login
var ref=window.location.href;
var appl=ref.split('/')[3];
var redir=appl+'.redirecturl';
// debugger;
if (ref.includes('index.php') == 0 && $j('.navbar-text').not('.navbar-right').length == 0) {
                sessionStorage.setItem(redir, ref);
				$j(location).attr('href','index.php?signIn=1');
}
else {
	if ($j('.navbar-text').not('.help-shortcuts-launcher-container').length != 0 && sessionStorage.hasOwnProperty(redir)) {
				   ref=sessionStorage.getItem(redir);
				   sessionStorage.removeItem(redir);
				   $j(location).attr('href', ref);
	}
}
 </script>

Re: get to specified page after login

Posted: 2021-02-10 21:01
by aarlauskas
Thank You Pascal, appreciate that!

Re: get to specified page after login

Posted: 2021-09-13 01:01
by ltlow
Not working for me in Appgini 5.97. When clicking the records link, it redirect to login page. After login , it go to index page and not get to the record link.

Re: get to specified page after login

Posted: 2021-09-13 03:12
by ltlow
And this breaking the adding new record from other table lookup field. Showing I am not login.