fa4766bae7b4b6256e2c72d07da8867d7da130f3
max
  Fri May 5 12:49:02 2017 -0700
CIRM: my last commit had a bug in the case where returnto was set. Fixing this and also fixing the returnto URLs of the CDW. Also documenting the new hg.conf option.

diff --git src/hg/hgLogin/hgLogin.c src/hg/hgLogin/hgLogin.c
index ba7dc00..02d51d0 100644
--- src/hg/hgLogin/hgLogin.c
+++ src/hg/hgLogin/hgLogin.c
@@ -292,36 +292,36 @@
 struct slName *newCookies = loginLoginUser(userName, idx), *sl;
 for (sl = newCookies;  sl != NULL;  sl = sl->next)
     dyStringPrintf(result, " document.cookie = '%s';", sl->name);
 return result; 
 }
 
 char *getReturnToURL()
 /* get URL from cart var returnto; if empty, make URL to hgSession on login host.  */
 {
 char *returnURL = cartUsualString(cart, "returnto", "");
 char *hgLoginHost = wikiLinkHost();
 char *cgiDir = cgiScriptDirUrl();
 char returnTo[2048];
 
 boolean relativeLink = cfgOptionBooleanDefault("login.relativeLink", FALSE);
-// reverse proxies and all-https sites have no need for absolute links
+if (!returnURL || sameString(returnURL,""))
     if (relativeLink)
+        // reverse proxies and all-https sites have no need for absolute links
        safef(returnTo, sizeof(returnTo), "%shgSession?hgS_doMainPage=1", cgiDir);
-else if (!returnURL || sameString(returnURL,""))
-   safef(returnTo, sizeof(returnTo),
-        "http%s://%s%shgSession?hgS_doMainPage=1",
+   else 
+       safef(returnTo, sizeof(returnTo), "http%s://%s%shgSession?hgS_doMainPage=1",
         cgiAppendSForHttps(), hgLoginHost, cgiDir);
 else
    safecpy(returnTo, sizeof(returnTo), returnURL);
 return cloneString(returnTo);
 }
 
 void returnToURL(int delay)
 /* delay for delay mill-seconds then return to the "returnto" URL */
 {
 char *returnURL = getReturnToURL();
 jsInlineF(
     "setTimeout(function(){location='%s';}, %d);\n"
     , returnURL, delay);
 }