6e42d75d18cc9c8b59ba22448d4bb5412bcf2c91 chinhli Mon Jun 18 13:25:03 2012 -0700 Finish soft code domain name. diff --git src/hg/hgLogin/hgLogin.c src/hg/hgLogin/hgLogin.c index d18bf48..7cb67d2 100644 --- src/hg/hgLogin/hgLogin.c +++ src/hg/hgLogin/hgLogin.c @@ -1024,69 +1024,70 @@ return; } boolean usingNewPassword(struct sqlConnection *conn, char *userName) /* The user is using requested new password */ { char query[256]; safef(query,sizeof(query), "select passwordChangeRequired from gbMembers where userName='%s'", userName); char *change = sqlQuickString(conn, query); if (change && sameString(change, "Y")) return TRUE; else return FALSE; } -char *cookieDomainName() -/* Return the domain name to be used by the cookies or NULL. Allocd - * here. */ -/* Return central.domain if the returnToURL is also in the same domain - * */ -/* else return the domain in returnTo URL generated by (remote) - * hgSession.*/ +char *getCookieDomainName() +/* Return domain name to be used by the cookies or NULL. Allocd here. */ +/* Return central.domain if returnToURL is also in the same domain. */ +/* else return the domain in returnTo URL generated by remote hgSession.*/ { char *centralDomain=cloneString(cfgOption(CFG_CENTRAL_DOMAIN)); char *returnURL = getReturnToURL(); char returnToDomain[256]; -sscanf(returnURL, "http://%[^/]", returnToDomain); + +/* parse the URL */ +struct netParsedUrl rtpu; +netParseUrl(returnURL, &rtpu); +safecpy(returnToDomain, sizeof(returnToDomain), rtpu.host); if (endsWith(returnToDomain,centralDomain)) return centralDomain; else return cloneString(returnToDomain); } void displayLoginSuccess(char *userName, int userID) /* display login success msg, and set cookie */ { hPrintf("

UCSC Genome Browser

" "

" "

" "" "\n"); /* Set cookies */ -char *domainName=cookieDomainName(); +char *domainName=getCookieDomainName(); hPrintf("\n" "" "\n", userName, domainName, userID, domainName); cartRemove(cart,"hgLogin_userName"); -returnToURL(15); +returnToURL(150); } void displayLogin(struct sqlConnection *conn) /* display and process login info */ { struct sqlResult *sr; char **row; char query[256]; char *userName = cartUsualString(cart, "hgLogin_userName", ""); if (sameString(userName,"")) { freez(&errMsg); errMsg = cloneString("User name cannot be blank."); displayLoginPage(conn); return; @@ -1142,31 +1143,31 @@ errMsg = cloneString("Invalid user name or password."); displayLoginPage(conn); return; } gbMembersFree(&m); } void displayLogoutSuccess() /* display logout success msg, and reset cookie */ { hPrintf("

UCSC Genome Browser Sign Out

" "

" "

" "" "\n"); -char *domainName=cookieDomainName(); +char *domainName=getCookieDomainName(); hPrintf("\n", domainName, domainName); /* return to "returnto" URL */ returnToURL(150); } void doMiddle(struct cart *theCart) /* Write the middle parts of the HTML page. * This routine sets up some globals and then * dispatches to the appropriate page-maker. */ { struct sqlConnection *conn = hConnectCentral();