ff523431c32a70a2c9f278694db20a299d01f206 kent Sat Feb 28 11:21:02 2015 -0800 A little refactoring so can reuse login system for CIRM. diff --git src/hg/lib/wikiLink.c src/hg/lib/wikiLink.c index a08fa69..0ec296e 100644 --- src/hg/lib/wikiLink.c +++ src/hg/lib/wikiLink.c @@ -77,85 +77,100 @@ 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 retBuf[1024]; safef(retBuf, sizeof(retBuf), "http%s://%s/cgi-bin/hgSession?hgsid=%s", cgiAppendSForHttps(), cgiServerNamePort(), hgsid); return cgiEncode(retBuf); } -char *wikiLinkUserLoginUrl(char *hgsid) + + +char *wikiLinkUserLoginUrlReturning(char *hgsid, char *returnUrl) /* Return the URL for the wiki user login page. */ { char buf[2048]; -char *retEnc = encodedHgSessionReturnUrl(hgsid); if (loginSystemEnabled()) { if (! wikiLinkEnabled()) errAbort("wikiLinkUserLoginUrl called when login system is not enabled " "(specified in hg.conf)."); safef(buf, sizeof(buf), "http%s://%s/cgi-bin/hgLogin?hgLogin.do.displayLoginPage=1&returnto=%s", - cgiAppendSForHttps(), wikiLinkHost(), retEnc); + cgiAppendSForHttps(), wikiLinkHost(), returnUrl); } else { if (! wikiLinkEnabled()) errAbort("wikiLinkUserLoginUrl called when wiki is not enabled (specified " "in hg.conf)."); safef(buf, sizeof(buf), "http://%s/index.php?title=Special:UserloginUCSC&returnto=%s", - wikiLinkHost(), retEnc); + wikiLinkHost(), returnUrl); } -freez(&retEnc); return(cloneString(buf)); } -char *wikiLinkUserLogoutUrl(char *hgsid) +char *wikiLinkUserLoginUrl(char *hgsid) +/* Return the URL for the wiki user login page with return going to hgSessions. */ +{ +char *retUrl = encodedHgSessionReturnUrl(hgsid); +char *result = wikiLinkUserLoginUrlReturning(hgsid, retUrl); +freez(&retUrl); +return result; +} + +char *wikiLinkUserLogoutUrlReturning(char *hgsid, char *returnUrl) /* Return the URL for the wiki user logout page. */ { char buf[2048]; -char *retEnc = encodedHgSessionReturnUrl(hgsid); - if (loginSystemEnabled()) { if (! wikiLinkEnabled()) errAbort("wikiLinkUserLogoutUrl called when login system is not enabled " "(specified in hg.conf)."); safef(buf, sizeof(buf), "http%s://%s/cgi-bin/hgLogin?hgLogin.do.displayLogout=1&returnto=%s", - cgiAppendSForHttps(), wikiLinkHost(), retEnc); + cgiAppendSForHttps(), wikiLinkHost(), returnUrl); } else { if (! wikiLinkEnabled()) errAbort("wikiLinkUserLogoutUrl called when wiki is not enable (specified " "in hg.conf)."); safef(buf, sizeof(buf), "http://%s/index.php?title=Special:UserlogoutUCSC&returnto=%s", - wikiLinkHost(), retEnc); + wikiLinkHost(), returnUrl); } -freez(&retEnc); return(cloneString(buf)); } +char *wikiLinkUserLogoutUrl(char *hgsid) +/* Return the URL for the wiki user logout page that returns to hgSessions. */ +{ +char *retEnc = encodedHgSessionReturnUrl(hgsid); +char *result = wikiLinkUserLoginUrlReturning(hgsid, retEnc); +freez(&retEnc); +return result; +} + char *wikiLinkUserSignupUrl(char *hgsid) /* Return the URL for the user signup page. */ { char buf[2048]; char *retEnc = encodedHgSessionReturnUrl(hgsid); if (loginSystemEnabled()) { if (! wikiLinkEnabled()) errAbort("wikiLinkUserSignupUrl called when login system is not enabled " "(specified in hg.conf)."); safef(buf, sizeof(buf), "http%s://%s/cgi-bin/hgLogin?hgLogin.do.signupPage=1&returnto=%s", cgiAppendSForHttps(), wikiLinkHost(), retEnc); }