Without looking into the source code (which I plan to do this weekend), I won't assume that it would be easy to make this happen, but essentially what I would do is this:
1) Upon receiving the "invalid" response from "gargoyle_session_validator", append redirected URL (login.sh, I believe) with "?last=LASTPAGENAME.sh" (e.g. ROUTER_IP://login.sh?last=bandwidth).
<edit>
2) Add a listener to the validator to check for appended URLs.
</edit>
3) Upon successful login, redirect to the reference in the URL and remove the appended reference.
I may be able to accomplish this with injected JS, and if I do, I will post my code for those who want the same capability.
Return to Last Page after Successful Login
Moderator: Moderators
Re: Return to Last Page after Successful Login
I’m interested in this and happy to look at implementing.
Any starting code is a good help
Any starting code is a good help
https://lantisproject.com/downloads/gargoylebuilds for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.
Please be respectful when posting. I do this in my free time on a volunteer basis.
Re: Return to Last Page after Successful Login
As promised, albeit a little quick and dirty. I haven't thoroughly tested this, but it seems to work pretty good in Chrome (62.0.3202.94 OB 64-bit):
JS:
Injected using this Chrome extension (Custom JavaScript for websites).
***
I don't think I used any jQuery, so I didn't load any external script(s). To make things easier, I relied on sessionStorage / localStorage, but this accomplishes mostly the same thing. There is the unfortunate initial load of "overview.sh", but it doesn't take too long.
JS:
Code: Select all
/*
GARGOYLE REDIRECTOR: LAST PAGE VIEWED
Decide how you want the script to behave.
You may disable the script, or choose to redirect only from within the
existing browsing session or between browsing sessions (i.e. from within
the same browser tab or even after a tab has been closed).
Set "redirectOpt" to one of the following:
0 = Disabled (default)
1 = Redirect back to the last page within existing browsing session
2 = Redirect back to the last page between browsing sessions
NOTE: No support for multiple browsing sessions open simultaneously;
however, it should function from the last page viewed in any open
browser tab.
*/
var redirectOpt = 0,
loginPage = 'login.sh',
defaultPage = 'overview.sh';
if (redirectOpt !== 0) {
var currentPage =
location.href.split('/')[location.href.split('/').length-1];
// Trim appended logout caller to make identifying login page easier
if (currentPage.indexOf('?logout=1') > -1) {
currentPage = currentPage.split('?')[0];
}
if (isNaN(redirectOpt) === false) {
if (browserTest(redirectOpt) === true) {
if (currentPage !== loginPage &&
currentPage !== defaultPage &&
currentPage !== '') {
setStorageVal(redirectOpt, 'lastPage', currentPage);
}
else {
if (currentPage === loginPage || currentPage === '') {
if (checkStorageVal(redirectOpt, 'lastPage') !== false) {
setStorageVal(redirectOpt, 'triggerRedirect', '1');
}
}
else {
if (checkStorageVal(redirectOpt, 'lastPage') !== false &&
checkStorageVal(redirectOpt, 'triggerRedirect') !== false) {
if (checkStorageVal(redirectOpt, 'triggerRedirect', 'y') === '1') {
window.stop();
setStorageVal(redirectOpt, 'triggerRedirect', '0');
window.location.href =
location.protocol + "//" +
location.hostname +
(location.port > 0 ? ":" + location.port : '') +
'/' + checkStorageVal(redirectOpt, 'lastPage', 'y');
}
}
}
}
}
else {
alert('You must have a browser that supports "'+
(redirectOpt === 1 ? 'sessionStorage' : 'localStorage') +
'" and it must be enabled to utilize this script.');
}
}
else {
alert('Variable "redirectOpt" must be set to a valid number (e.g. 0, 1, or 2).');
}
}
function browserTest(option) {
if (option === 1) {
if (typeof(sessionStorage) !== 'undefined') {
return wrapCheck(option);
}
else {
return false;
}
}
else {
if (typeof(localStorage) !== 'undefined') {
return wrapCheck(option);
}
else {
return false;
}
}
function wrapCheck(option) {
setStorageVal(option, 'testStore', 'success');
if (checkStorageVal(option, 'testStore') !== false &&
checkStorageVal(option, 'testStore', 'y') === 'success') {
return true;
}
else {
return false;
}
}
}
function setStorageVal(option, key, val) {
if (option === 1) {
sessionStorage[key] = val;
}
else {
localStorage[key] = val;
}
}
function checkStorageVal(option, key, get) {
if (option === 1) {
if (typeof(sessionStorage[key]) !== 'undefined') {
if (!get) {
return true;
}
else {
return sessionStorage[key];
}
}
else {
return false;
}
}
else {
if (typeof(localStorage[key]) !== 'undefined') {
if (!get) {
return true;
}
else {
return localStorage[key];
}
}
else {
return false;
}
}
}
***
I don't think I used any jQuery, so I didn't load any external script(s). To make things easier, I relied on sessionStorage / localStorage, but this accomplishes mostly the same thing. There is the unfortunate initial load of "overview.sh", but it doesn't take too long.