get to specified page after login

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

get to specified page after login

Post by pbottcher » 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>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
aarlauskas
Veteran Member
Posts: 127
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: 90
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: 127
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?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: get to specified page after login

Post by pbottcher » 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>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
aarlauskas
Veteran Member
Posts: 127
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!

ltlow
Posts: 15
Joined: 2021-07-29 09:37

Re: get to specified page after login

Post by ltlow » 2021-09-13 01:01

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.

ltlow
Posts: 15
Joined: 2021-07-29 09:37

Re: get to specified page after login

Post by ltlow » 2021-09-13 03:12

And this breaking the adding new record from other table lookup field. Showing I am not login.

Post Reply