fd0b25bc78b9419bf7f4ed8d9f854f85831344d6 chinhli Mon Apr 9 11:27:46 2012 -0700 fixed signup UI diff --git src/hg/hgLogin/hgLogin.c src/hg/hgLogin/hgLogin.c index 3c09d3a..6c0bdbe 100644 --- src/hg/hgLogin/hgLogin.c +++ src/hg/hgLogin/hgLogin.c @@ -15,31 +15,31 @@ #include "web.h" #include "ra.h" #include "hgColors.h" #include <crypt.h> #include "net.h" #include "hgLogin.h" #include "hgLoginLink.h" #include "gbMembers.h" #include "versionInfo.h" char msg[2048] = ""; -char *excludeVars[] = { "submit", "Submit", "debug", "fixMembers", "update", "hgLogin_password", NULL }; +char *excludeVars[] = { "submit", "Submit", "debug", "fixMembers", "update", "hgLogin_password","hgLogin_confirmPWD", NULL }; /* The excludeVars are not saved to the cart. (We also exclude * any variables that start "near.do.") */ /* ---- Global variables. ---- */ struct cart *cart; /* This holds cgi and other variables between clicks. */ char *database; /* Name of genome database - hg15, mm3, or the like. */ struct hash *oldCart; /* Old cart hash. */ char *errMsg; /* Error message to show user when form data rejected */ /* -------- password functions ---- */ void encryptPWD(char *password, char *salt, char *buf, int bufsize) /* encrypt a password */ { /* encrypt user's password. */ @@ -432,88 +432,88 @@ "Signing in enables you to save current settings into a " "named session, and then restore settings from the session later.<BR> " "If you wish, you can share named sessions with other users. " "</P>" ); hPrintf( "If you are already a member, click <a href=\"hgLogin?hgLogin.do.displayLoginPage=1\">here</a> to log in to UCSC Genome Browser.<br>\n" "To change your password, click <a href=\"hgLogin?hgLogin.do.changePasswordPage=1\">here</a>.<br>\n" "Lost your password? Click <a href=\"hgLogin?hgLogin.do.lostPasswordPage=1\">here</a>.<br>\n" ); hPrintf( "<h3>Sign Up</h3>" "\n" -"<form method=post action=\"hgLoginSignup\" name=signupForm >" +"<form method=post action=\"hgLogin\" name=mainForm >" "<span style='color:red;'>%s</span>" , errMsg ? errMsg : "" ); hPrintf( "<label style=\"display: block; margin-top: 10px;\" " " for=\"userName\">User Name</label>" "\n" -"<input type=text name=\"hgSignup_userName\" value=\"%s\" size=\"30\" id=\"userName\"> <br>" +"<input type=text name=\"hgLogin_user\" value=\"%s\" size=\"30\" id=\"userName\"> <br>" "\n" "<label style=\"display: block; margin-top: 10px;\" " " for=\"emailAddr\">E-mail</label>" "\n" -"<input type=text name=\"hgSignup_emailAddr\" value=\"%s\" size=\"30\" id=\"emailAddr\"> <br>" +"<input type=text name=\"hgLogin_email\" value=\"%s\" size=\"30\" id=\"emailAddr\"> <br>" "\n" "<label style=\"display: block; margin-top: 10px;\" " " for=\"password\">Password</label>" "\n" -"<input type=password name=\"hgSignup_password\" value=\"\" size=\"30\" id=\"password\">" +"<input type=password name=\"hgLogin_password\" value=\"%s\" size=\"30\" id=\"password\">" "\n" "<label style=\"display: block; margin-top: 10px;\" " " for=\"confirmPW\">Confirm Password</label>" "\n" -"<input type=password name=\"hgSingup_confirmPWD\" value=\"\" size=\"30\" id=\"confirmPWD\">" +"<input type=password name=\"hgLogin_confirmPWD\" value=\"%s\" size=\"30\" id=\"confirmPWD\">" "\n" "<label style=\"display: block; margin-top: 10px;\" " " for=\"realName\">Real Name (optional)</label>" "\n" -"<input type=text name=\"hgSignup_realName\" value=\"%s\" size=\"30\" id=\"realName\"> <br>" +"<input type=text name=\"hgLogin_realName\" value=\"%s\" size=\"30\" id=\"realName\"> <br>" "\n" /******** "<tr><td>Name</td><td><input type=text name=hgLogin_user value=\"%s\" size=20></td></tr>\n" "<tr><td>E-mail</td><td><input type=text name=hgLogin_email value=\"%s\"size=20>\n" "<tr><td>Password</td><td><input type=password name=hgLogin_password value=\"%s\" size=10></td></tr>\n" "<tr><td>Real name (optional)</td><td><input type=text name=hgLogin_realName value=\"%s\" size=20></td></tr>\n" "<tr><td> </td><td><input type=submit name=hgLogin.do.signup value=submit>" " <input type=button value=cancel ONCLICK=\"history.go(-1)\"></td></tr>\n" "<br>\n" , cartUsualString(cart, "hgLogin_user", "") , cartUsualString(cart, "hgLogin_email", "") //, cartUsualString(cart, "hgLogin_password", "") , cartUsualString(cart, "hgLogin_realName", "") ); ****************/ "<p>" "<tr><td> </td><td><input type=submit name=hgLogin.do.signup value=submit>" " <input type=button value=cancel ONCLICK=\"history.go(-1)\"></td></tr>\n" "<br>\n" "</p>" -, cartUsualString(cart, "hgSignup_user", "") -, cartUsualString(cart, "hgSignup_email", "") -, cartUsualString(cart, "hgSignup_password", "") -, cartUsualString(cart, "hgSignup_confirmPWD", "") -, cartUsualString(cart, "hgSignup_realName", "") +, cartUsualString(cart, "hgLogin_user", "") +, cartUsualString(cart, "hgLogin_email", "") +, cartUsualString(cart, "hgLogin_password", "") +, cartUsualString(cart, "hgLogin_confirmPWD", "") +, cartUsualString(cart, "hgLogin_realName", "") ); cartSaveSession(cart); hPrintf("</FORM>"); } void signup(struct sqlConnection *conn) /* process the signup form */ { char query[256]; char *user = cartUsualString(cart, "hgLogin_user", ""); @@ -568,51 +568,69 @@ char encPwd[35] = ""; encryptNewPwd(password, encPwd, sizeof(encPwd)); safef(query,sizeof(query), "insert into gbMembers set " "userName='%s',realName='%s',password='%s',email='%s', " "lastUse=NOW(),activated='N',dateAuthenticated='9999-12-31 23:59:59'", sqlEscapeString(user),sqlEscapeString(realName),sqlEscapeString(encPwd),sqlEscapeString(email)); sqlUpdate(conn, query); hPrintf( "<h2>UCSC Genome Browser</h2>\n" "<p align=\"left\">\n" "</p>\n" "<h3>User %s successfully added.</h3>\n" -, email +, user ); +backToHgSession(2); +/* +char *hgLoginHost = hgLoginLinkHost(); hPrintf( -"Click <a href=hgLogin?hgLogin.do.signupPage=1>here</a> to return.<br>\n" -); +"<script language=\"JavaScript\">\n" +"<!-- " +"\n" +"window.setTimeout(afterDelay, 1000);\n" +"function afterDelay() {\n" +"window.location =\"http://%s/cgi-bin/hgSession?hgS_doMainPage=1\";" +"\n}" +"\n" +"//-->" +"\n" +"</script>" +,hgLoginHost); +*/ + +//hPrintf( +//"Click <a href=hgLogin?hgLogin.do.signupPage=1>here</a> to return.<br>\n" +//); } /* ----- account login/display functions ---- */ void displayLoginPage(struct sqlConnection *conn) /* draw the account login page */ { char *username = cartUsualString(cart, "hgLogin_userName", ""); /* for password security, use cgi hash instead of cart */ -// char *password = cgiUsualString("hgLogin_password", ""); +char *password = cgiUsualString("hgLogin_password", ""); hPrintf( "<div id=\"hgLoginBox\" class=\"centeredContainer\">\n" "<h2>UCSC Genome Browser</h2>" "\n" ); printf( "<P>" "Signing in enables you to save current settings into a " "named session, and then restore settings from the session later.<BR> " "If you wish, you can share named sessions with other users. " "</P>" ); hPrintf( "<span style='color:red;'>%s</span>" @@ -774,51 +792,72 @@ hPrintf( "<h2>UCSC Genome Browser Sign Out</h2>" "<p align=\"left\">" "</p>" "<span style='color:red;'></span>" "\n" ); hPrintf( "<script language=\"JavaScript\">" "document.cookie = \"hgLogin_UserName=; domain=ucsc.edu; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/\"; " "\n" "document.cookie = \"hgLogin_UserID=; domain=ucsc.edu; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/\";" "</script>\n" ); /* return to session */ -/*******************************/ +backToHgSession(1); +/******************************* hPrintf( "<script language=\"JavaScript\">\n" "<!-- " "\n" -/* delay for 5 seconds then go back to page X */ -/* TODO: afterDelayBackTo("http....") */ "window.setTimeout(afterDelay, 1000);\n" "function afterDelay() {\n" "window.location =\"http://%s/cgi-bin/hgSession?hgS_doMainPage=1\";" "\n}" "\n" "//-->" "\n" "</script>" ,hgLoginHost); -/****************************/ +****************************/ } +void backToHgSession(int nSec) +/* delay for N micro seconds then go back to hgSession page */ +/* TODO: afterDelayBackTo("http....") */ +{ +char *hgLoginHost = hgLoginLinkHost(); +int delay=nSec*1000; +hPrintf( +"<script language=\"JavaScript\">\n" +"<!-- " +"\n" +/* TODO: afterDelayBackTo("http....") */ +"window.setTimeout(afterDelay, %d);\n" +"function afterDelay() {\n" +"window.location =\"http://%s/cgi-bin/hgSession?hgS_doMainPage=1\";" +"\n}" +"\n" +"//-->" +"\n" +"</script>" +,delay +,hgLoginHost); +} void displayUserInfo(struct sqlConnection *conn) /* display user account info */ { struct sqlResult *sr; char **row; char query[256]; char *user = cartUsualString(cart, "hgLogin_user", ""); /*************************************/ if (sameString(user,"")) { freez(&errMsg); errMsg = cloneString("User name cannot be blank."); displayUserInfo(conn); return;