Logout Redirect: to a link of your choice!
4 posters
Page 1 of 1
Logout Redirect: to a link of your choice!
Hello everybody!
What if we can redirect the logout to a specific link determined by us?
It's easy, see the code below!
In your ACP: Modules -> HTML&JAVASCRIPT -> JavaScript codes management -> [Create a new JavaScript]
Title *: <- Whatever you want
Placement : <- In all the pages
Javascript Code * : <- Select, copy and paste the code below in this field:
I await your feedback,
JS
What if we can redirect the logout to a specific link determined by us?
It's easy, see the code below!
In your ACP: Modules -> HTML&JAVASCRIPT -> JavaScript codes management -> [Create a new JavaScript]
Title *: <- Whatever you want
Placement : <- In all the pages
Javascript Code * : <- Select, copy and paste the code below in this field:
- Code:
/***
* Application: LogoutRedirect.js
* Description: Logout redirect to a link of your choice!
* Version: 0.02282015-jq1.9.1
* RC1 (Release candidate 1!) - ébé
* Author: JScript - 2015/02/28
* Copyright (c) 2015 JScript <jscriptbrasil at live dot com>
* This work is free. You can redistribute it and/or modify it
* under the terms of the WTFPL, Version 2
*/
var LogoutRedirect = '/portal' ; // <- Change the link for what you want!
if (localStorage.getItem("logout")) {
localStorage.removeItem("logout");
location.href = LogoutRedirect;
};
jQuery(function() {
if (!_userdata.session_logged_in) {
return false;
}
var _ToolBar = setInterval(function() {
if (document.getElementById('fa_welcome') !== null) {
clearInterval(_ToolBar);
jQuery('a[href$="logout=1"]').attr('href', jQuery('#logout').attr('href'));
jQuery('a[href*="logout=1"]').click(function(event) {
localStorage.setItem("logout", 1);
});
}
}, 1000);
});
I await your feedback,
JS
Re: Logout Redirect: to a link of your choice!
It's not a bad Idea. I was wondering, wouldn't it be better to just use cookies instead of localStorage ? This way older browsers that don't support the Storage API can also make use of this plugin.
I also noticed that LogoutRedirect had a global scope when you can simply wrap it in an anonymous function to keep it local, unless there was a reason it needed to be global ? Lastly would be the polling for the toolbar; I found that initiating a second document ready event applies what you need as soon as the toolbar ( and sceditor ) are ready.
This would be my suggestion to improving it :
I like this overall
I also noticed that LogoutRedirect had a global scope when you can simply wrap it in an anonymous function to keep it local, unless there was a reason it needed to be global ? Lastly would be the polling for the toolbar; I found that initiating a second document ready event applies what you need as soon as the toolbar ( and sceditor ) are ready.
This would be my suggestion to improving it :
- Code:
// use an anonymous function so our variables have a local scope
(function() {
// startup variables
var redirection = '/t1-', // redirect link
logout, // logout link
menu, // toolbar menulist
setState = function() { my_setcookie('faLogout', 'true') }; // set the cookie state
// if the cookie isn't empty, redirection will occur
if (my_getcookie('faLogout')) {
my_setcookie('faLogout', ''); // empty the cookie
window.location.href = redirection; // redirect the user
}
// execution for when the document is ready
$(function() {
if (!_userdata.session_logged_in) return; // return if the user is logged out
logout = document.getElementById('logout'); // get and set the logout button
logout.onclick = setState; // set the cookie on click
// ecxecution for when the toolbar is ready
$(function() {
menu = document.getElementById('fa_menulist'); // get and set the menulist
// if the menu isn't null, the following will be executed
if (menu) {
menu = menu.lastChild.firstChild; // change the menu to the logout option
menu.href = logout.href; // change the href so the tid and key can initiate an instant logout
menu.onclick = setState; // set the cookie on click
}
});
});
})();
I like this overall
Re: Logout Redirect: to a link of your choice!
@Ange Tuteur
Yes, a great improvement, very good!!!
That's what we need: Discuss and make improvements in the codes!!!
So far the best change: https://help.forumotion.com/t141384-logout-redirect-to-a-link-of-your-choice#962688
JS
Yes, a great improvement, very good!!!
That's what we need: Discuss and make improvements in the codes!!!
So far the best change: https://help.forumotion.com/t141384-logout-redirect-to-a-link-of-your-choice#962688
JS
Re: Logout Redirect: to a link of your choice!
Hello @JScript
nice resource I must tell
just a little "suggestion".. it could be useful to have this redirect even on login
maybe an admin wants its member to be redirected to an html page after the login
what do you think?
nice resource I must tell
just a little "suggestion".. it could be useful to have this redirect even on login
maybe an admin wants its member to be redirected to an html page after the login
what do you think?
Re: Logout Redirect: to a link of your choice!
@Niko
A great idea, that would be the reverse of the actual code or we can merge all?
So far the best change: https://help.forumotion.com/t141384-logout-redirect-to-a-link-of-your-choice#962688
JS
A great idea, that would be the reverse of the actual code or we can merge all?
So far the best change: https://help.forumotion.com/t141384-logout-redirect-to-a-link-of-your-choice#962688
JS
Re: Logout Redirect: to a link of your choice!
This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» The logout link
» Link to Automatic logout
» Redirect link in a page
» automatic logout
» logout and i see myself online!
» Link to Automatic logout
» Redirect link in a page
» automatic logout
» logout and i see myself online!
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum