varRedirectLogin=RedirectLogin||{};RedirectLogin.init=function(){// example: /secure/Dashboard.jspavarpathname=window.location.pathname;// login page URLvarloginUrl="/login.jsp";// is user already on JIRA login page?varisOnLoginUrl=loginUrl.match(pathname)!==null;// Is a full JIRA user already logged in?varisJIRAUserLoggedIn=JIRA.Users.LoggedInUser.userName().length>0;// JIRA user is already logged in and yet on the login page; so, redirect to Dashboardif(isJIRAUserLoggedIn&&isOnLoginUrl)window.location="/secure/Dashboard.jspa";if(!isJIRAUserLoggedIn&&!RedirectLogin.isURLToRedirect(pathname)&&!isOnLoginUrl){// do redirect// the querystring part of a URLvarqueryStr=window.location.search;window.location=loginUrl+queryStr;}};// is this a URL to redirect to the login page?RedirectLogin.isURLToRedirect=function(pathname){varshouldRedirect=false;varforgotPassUrl=/^\/secure\/ForgotLoginDetails.jspa$/;varresetPassUrl=/^\/secure\/ResetPassword!default.jspa/;if(forgotPassUrl.test(pathname)||resetPassUrl.test(pathname)){shouldRedirect=true;}returnshouldRedirect;};RedirectLogin.init();
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.