get to specified page after login

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1249
Joined: 2018-04-01 10:12

get to specified page after login

Post by pböttcher » 2020-07-03 19:58

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>

User avatar
aarlauskas
Veteran Member
Posts: 108
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: get to specified page after login

Post by aarlauskas » 2020-07-14 21:18

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!

nycwebmaster
Veteran Member
Posts: 83
Joined: 2015-11-23 01:02

Re: get to specified page after login

Post by nycwebmaster » 2020-07-15 18:00

It Works! Thanks! BTW I will send you an email.

User avatar
aarlauskas
Veteran Member
Posts: 108
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: get to specified page after login

Post by aarlauskas » 2021-01-17 20:21

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?

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1249
Joined: 2018-04-01 10:12

Re: get to specified page after login

Post by pböttcher » 2021-02-10 15:38

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>

User avatar
aarlauskas
Veteran Member
Posts: 108
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: get to specified page after login

Post by aarlauskas » 2021-02-10 21:01

Thank You Pascal, appreciate that!

Post Reply