c70f751f0a951b914adbc804d21f69426d764ea7 max Tue Jan 21 03:44:01 2014 -0800 change hgLogin to allow deactivating the email confirmation email viahg.conf refs #11957 diff --git src/hg/hgLogin/hgLogin.c src/hg/hgLogin/hgLogin.c index 8f430b9..66702c7 100644 --- src/hg/hgLogin/hgLogin.c +++ src/hg/hgLogin/hgLogin.c @@ -75,31 +75,33 @@ return cloneString("NULL_browserAddr"); else return cloneString(cfgOption(CFG_LOGIN_BROWSER_ADDR)); } char *mailSignature() /* Return the signature to be used by outbound mail or NULL. Allocd here. */ { if isEmpty(cfgOption(CFG_LOGIN_MAIL_SIGNATURE)) return cloneString("NULL_mailSignature"); else return cloneString(cfgOption(CFG_LOGIN_MAIL_SIGNATURE)); } char *mailReturnAddr() -/* Return the return addr. to be used by outbound mail or NULL. Allocd here. */ +/* Return the return addr. to be used by outbound mail or NULL. Allocd here. + * If set to "NOEMAIL" then no email will be sent and the account is activated right away. + * */ { if isEmpty(cfgOption(CFG_LOGIN_MAIL_RETURN_ADDR)) return cloneString("NULL_mailReturnAddr"); else return cloneString(cfgOption(CFG_LOGIN_MAIL_RETURN_ADDR)); } /* ---- password functions depend on optionally installed openssl lib ---- */ #ifdef USE_SSL #include void cryptWikiWay(char *password, char *salt, char* result) /* encrypt password in mediawiki format - ':B:'.$salt.':'. md5($salt.'-'.md5($password ) */ { @@ -338,73 +340,77 @@ void returnToURL(int delay) /* delay for delay mill-seconds then return to the "returnto" URL */ { char *returnURL = getReturnToURL(); hPrintf( "", delay, returnURL); } +static void redirectToLoginPage(char *paramStr) +/* redirect to hgLogin page with given parameter string */ +{ +char *hgLoginHost = wikiLinkHost(); +hPrintf("", cgiAppendSForHttps(), hgLoginHost, paramStr); +} + void displayActMailSuccess() /* display Activate mail success box */ { char *returnURL = getReturnToURL(); hPrintf( "
" "\n" "

%s

", brwName); hPrintf( "

A confirmation email has been sent to you. \n" "Please click the confirmation link in the email to activate your account.

" "\n" "

Return

", returnURL); cartRemove(cart, "hgLogin_email"); cartRemove(cart, "hgLogin_userName"); } void sendActMailOut(char *email, char *subject, char *msg) /* send mail to email address */ { -char *hgLoginHost = wikiLinkHost(); int result; result = mailViaPipe(email, subject, msg, returnAddr); if (result == -1) { hPrintf( "

%s

", brwName); hPrintf( "

" "

" "

Error emailing to: %s

" "Click here to return.
", email ); } else - { - hPrintf("", cgiAppendSForHttps(), hgLoginHost); - } + redirectToLoginPage("hgLogin.do.displayActMailSuccess=1"); } 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); hPrintf( @@ -1031,35 +1037,47 @@ errMsg = cloneString("Password field cannot be blank."); signupPage(conn); return; } if (password && password2 && !sameString(password, password2)) { freez(&errMsg); errMsg = cloneString("Passwords do not match."); signupPage(conn); return; } /* pass all the checks, OK to create the account now */ char encPwd[45] = ""; encryptNewPwd(password, encPwd, sizeof(encPwd)); +char *accActStatus = "N"; + +if (sameWord(returnAddr, "NOEMAIL")) + accActStatus = "Y"; + sqlSafef(query,sizeof(query), "INSERT INTO gbMembers SET " "userName='%s',realName='%s',password='%s',email='%s', " - "lastUse=NOW(),accountActivated='N'", - user,user,encPwd,email); + "lastUse=NOW(),accountActivated='%s'", + user,user,encPwd,email,accActStatus); sqlUpdate(conn, query); + +if (sameWord(returnAddr, "NOEMAIL")) + { + redirectToLoginPage("hgLogin.do.displayLoginPage=1"); + return; + } + setupNewAccount(conn, email, user); /* send out activate code mail, and display the mail confirmation box */ hPrintf("

%s

", brwName); hPrintf( "

\n" "

\n" "

User %s successfully added.

\n", user); cartRemove(cart, "hgLogin_email"); cartRemove(cart, "hgLogin_email2"); cartRemove(cart, "hgLogin_userName"); cartRemove(cart, "user"); cartRemove(cart, "token"); returnToURL(150); }