0dab88f8198e8e8d35bbb65673186ad8df1a7f64 max Thu Nov 7 06:49:40 2024 -0800 adding API key section to hgHubConnect, for the "hubtools up" command, refs #34405 diff --git src/hg/lib/wikiLink.c src/hg/lib/wikiLink.c index 1472457..b6bbcad 100644 --- src/hg/lib/wikiLink.c +++ src/hg/lib/wikiLink.c @@ -389,40 +389,54 @@ return cloneString(getLoginUserName()); } else if (wikiLinkEnabled()) { char *wikiUserName = findCookieData(wikiLinkUserNameCookie()); char *wikiLoggedIn = findCookieData(wikiLinkLoggedInCookie()); if (isNotEmpty(wikiLoggedIn) && isNotEmpty(wikiUserName)) return cloneString(wikiUserName); } else errAbort("wikiLinkUserName called when wiki is not enabled (specified " "in hg.conf)."); return NULL; } -static char *encodedHgSessionReturnUrl(char *hgsid) -/* Return a CGI-encoded hgSession URL with hgsid. Free when done. */ +char *wikiLinkUserId() +/* Return the user ID specified in cookies from the browser. Does not check if user is logged in. + * To make sure that the ID is valid, call this only after you have checked with wikiLinkUserName() that the user is logged in. */ +{ + return findCookieData(wikiLinkLoggedInCookie()); +} + +char *wikiLinkEncodeReturnUrl(char *hgsid, char *cgiName, char* urlSuffix) +/* Return a CGI-encoded URL with hgsid to a CGI. Free when done. */ { char retBuf[1024]; -safef(retBuf, sizeof(retBuf), "%shgSession?hgsid=%s", - hLocalHostCgiBinUrl(), hgsid); +safef(retBuf, sizeof(retBuf), "%s%s?hgsid=%s%s", + hLocalHostCgiBinUrl(), cgiName, hgsid, urlSuffix); return cgiEncode(retBuf); } +static char *encodedHgSessionReturnUrl(char *hgsid) +/* Return a CGI-encoded hgSession URL with hgsid. Free when done. */ +{ +return wikiLinkEncodeReturnUrl(hgsid, "hgSession", ""); +} + + //#*** TODO: replace all of the non-mediawiki "returnto"s here and in hgLogin.c with a #define char *wikiLinkUserLoginUrlReturning(char *hgsid, char *returnUrl) /* Return the URL for the wiki user login page. */ { char buf[2048]; if (loginSystemEnabled()) { safef(buf, sizeof(buf), "%s?hgLogin.do.displayLoginPage=1&returnto=%s", loginUrl(), returnUrl); } else {