43263c78ad44a4b1ab143ddde74e27b47e0e42d5 chinhli Thu Jul 18 23:19:53 2013 -0700 Feature #8922 Remove hard coded "http" string from hgLogin-related code in hgLogin and hgSession diff --git src/hg/hgLogin/hgLogin.c src/hg/hgLogin/hgLogin.c index cfa4cd5..4ac4ef4 100644 --- src/hg/hgLogin/hgLogin.c +++ src/hg/hgLogin/hgLogin.c @@ -316,31 +316,32 @@ if (*c <= ' ' || *c >= 127) return 0; if (strchr(rfc822_specials, *c)) return 0; } while (*++c); return (count >= 1); } char *getReturnToURL() /* get URL passed in with returnto URL */ { char *returnURL = cartUsualString(cart, "returnto", ""); char *hgLoginHost = wikiLinkHost(); char returnTo[2048]; if (!returnURL || sameString(returnURL,"")) safef(returnTo, sizeof(returnTo), - "http://%s/cgi-bin/hgSession?hgS_doMainPage=1", hgLoginHost); + "http%s://%s/cgi-bin/hgSession?hgS_doMainPage=1", + cgiAppendSForHttps(), hgLoginHost); 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(); hPrintf( "", hgLoginHost); + "", cgiAppendSForHttps(), hgLoginHost); } } void displayMailSuccess() /* display mail success confirmation box */ { char *sendMailTo = cartUsualString(cart, "hgLogin_sendMailTo", ""); hPrintf( "
" "

%s

", brwName); hPrintf( "

All usernames on file (if any) for %s " "have been sent to that address.

" " If %s is not your registered email address, you will not receive an email." " If you can't find the message we sent you, please contact %s for help.

", sendMailTo, sendMailTo, returnAddr); @@ -444,34 +445,34 @@ if (result == -1) { hPrintf( "

%s

", brwName); hPrintf( "

" "

" "

Error emailing %s to: %s

" "Click here to return.
", obj, email ); } else { hPrintf("", hgLoginHost); + "", cgiAppendSForHttps(), hgLoginHost); } } void mailUsername(char *email, char *users) /* send user name list to the email address */ { char subject[256]; char msg[4096]; char *remoteAddr=getenv("REMOTE_ADDR"); safef(subject, sizeof(subject),"Your user name at the %s", brwName); safef(msg, sizeof(msg), " Someone (probably you, from IP address %s) has requested user name(s) associated with this email address at the %s: \n\n %s\n\n%s\n%s", remoteAddr, brwName, users, signature, returnAddr); sendMailOut(email, subject, msg); @@ -511,34 +512,34 @@ if (result == -1) { hPrintf( "

%s

", brwName); hPrintf( "

" "

" "

Error emailing %s to: %s

" "Click here to return.
", obj, email ); } else { hPrintf("", hgLoginHost, username); + "", cgiAppendSForHttps(), hgLoginHost, username); } } void sendNewPwdMail(char *username, char *email, char *password) /* send user new password */ { char subject[256]; char msg[4096]; char *remoteAddr=getenv("REMOTE_ADDR"); safef(subject, sizeof(subject),"New temporary password for your account at the %s", brwName); safef(msg, sizeof(msg), " Someone (probably you, from IP address %s) requested a new password for the %s (%s). A temporary password for user \"%s\" has been created and was set to \"%s\". If this was your intent, you will need to log in and choose a new password now. Your temporary password will expire in 7 days.\n\n If someone else made this request, or if you have remembered your password, and you no longer wish to change it, you may ignore this message and continue using your old password.\n\n%s\n%s", remoteAddr, brwName, brwAddr, username, password, signature, returnAddr); sendPwdMailOut(email, subject, msg, username); @@ -647,32 +648,32 @@ cartRemove(cart, "hgLogin_changeRequired"); return; } void sendActivateMail(char *email, char *username, char *encToken) /* Send activation mail with token to user*/ { char subject[256]; char msg[4096]; char activateURL[256]; char *hgLoginHost = wikiLinkHost(); char *remoteAddr=getenv("REMOTE_ADDR"); char *urlEncodedUsername=replaceChars(username," ","%20"); safef(activateURL, sizeof(activateURL), - "http://%s/cgi-bin/hgLogin?hgLogin.do.activateAccount=1&user=%s&token=%s\n", - hgLoginHost, + "http%s://%s/cgi-bin/hgLogin?hgLogin.do.activateAccount=1&user=%s&token=%s\n", + cgiAppendSForHttps(), hgLoginHost, cgiEncode(urlEncodedUsername), cgiEncode(encToken)); safef(subject, sizeof(subject),"%s account e-mail address confirmation", brwName); safef(msg, sizeof(msg), " Someone (probably you, from IP address %s) has requested an account %s with this e-mail address on the %s.\nTo confirm that this account really does belong to you on the %s, open this link in your browser:\n\n%s\n\nIf this is *not* you, do not follow the link. This confirmation code will expire in 7 days.\n\n%s\n%s", remoteAddr, username, brwName, brwName, activateURL, signature, returnAddr); sendActMailOut(email, subject, msg); } void setupNewAccount(struct sqlConnection *conn, char *email, char *username) /* Set up new user account and send activation mail to user */ { char query[256]; char *token = generateRandomPassword(); char *tokenMD5 = generateTokenMD5(token);