716acb7dabc447ddf157ec96ad615a195b4df3d2 chinhli Fri Apr 6 15:59:16 2012 -0700 Finished hgLogin UI diff --git src/hg/hgLogin/hgLogin.c src/hg/hgLogin/hgLogin.c index 57568f9..636bc31 100644 --- src/hg/hgLogin/hgLogin.c +++ src/hg/hgLogin/hgLogin.c @@ -534,53 +534,82 @@ 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", ""); +// 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>" -"<p align=\"left\">" -"</p>" +"\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>" +, errMsg ? errMsg : "" +); +hPrintf( "<h3>Login</h3>" +"\n" "<form method=post action=\"hgLogin\" name=accountLoginForm >" -"<table>" -"<tr><td>User Name</td><td><input type=text name=hgLogin_userName value=\"%s\" size=20> <BR> " -"<tr><td>Password</td><td><input type=password name=hgLogin_password value=\"%s\" size=20></td></tr><BR>" -"</table>" -"<p><a href=\"hgLogin?hgLogin.do.lostPasswordPage=1\">Forgot</a> your password? <a href=\"hgLogin?do.signupPage=1\">Need an account</a>?</p>" -"<table>" -"<tr><td> </td><td><input type=submit name=hgLogin.do.displayLogin value=login>\n" +"\n"); +hPrintf( +"<label style=\"display: block; margin-top: 10px;\" " +" for=\"userName\">User Name</label>" +"\n" +"<input type=text name=\"hgLogin_userName\" value=\"\" size=\"30\" id=\"userName\"> <br>" +"\n" +"<label style=\"display: block; margin-top: 10px;\" " +" for=\"password\">Password</label>" +"\n" +"<input type=password name=\"hgLogin_password\" value=\"\" size=\"30\" id=\"password\">" +"\n" +"<p>" +"<a href=\"hgLogin?hgLogin.do.lostPasswordPage=1\">Forgot your password?</a><br>" +"<a href=\"hgLogin?do.signupPage=1\">Need an account</a>?" +"</p>" +"\n" +"<p>" +"<input type=\"submit\" name=\"hgLogin.do.displayLogin\" value=\"Login\" id=\"loginButton\">" +"\n" +// " <a href=\"\" onclick=\"history.go(-1)\">Cancel</a>" " <input type=button value=cancel ONCLICK=\"history.go(-1)\"></td></tr>" -"</table>" -"<BR>" -, errMsg ? errMsg : "" -, username -, password +"</p>" +"\n" +"</form>" +"</div><!-- END - hgLoginBox -->" +//, username +//, password ); cartSaveSession(cart); hPrintf("</FORM>"); } /******* BEGIN dispalyLogin *************************/ void displayLogin(struct sqlConnection *conn) /* display user account info */ { struct sqlResult *sr; char **row; @@ -614,123 +643,125 @@ displayLoginPage(conn); return; } struct gbMembers *m = gbMembersLoad(row); sqlFreeResult(&sr); /* TODO: check user name exist and activated */ /* ..... */ if (checkPwd(password,m->password)) { hPrintf("<h1>Login succesful !!!! calling displayLoginSuccess now.</h1>\n"); unsigned int userID=m->idx; hPrintf("Before call userID is %d\n",userID); displayLoginSuccess(userName,userID); -// htmlSetCookie("hgLogin_User", "chinhli", NULL, NULL, ".cse.ucsc.edu", FALSE); -// hPrintf("<meta http-equiv=\"set-cookie\" content=\"hgLogin_User=chinhli;expires=Fri, 30 Dec 2015 12:00:00 GMT; path=cse.ucsc.edu\">"); return; } else { hPrintf("<h1>Invalid User/Password</h1>\n"); hPrintf("Return to <a href=\"hgLogin\">signup</A>.<br>\n"); } gbMembersFree(&m); } /******* end old dispalyLogin *************************/ void displayLoginSuccess(char *userName, int userID) /* display login success msg, and set cookie */ { +char *hgLoginHost = hgLoginLinkHost(); + hPrintf( "<h2>UCSC Genome Browser</h2>" "<p align=\"left\">" "</p>" "<span style='color:red;'></span>" "\n" ); hPrintf( "<script language=\"JavaScript\">" " document.write(\"Login successful, setting cookies now...\");" " document.write(\" in Call userID is %d\n\");" "</script>\n" "<script language=\"JavaScript\">" "document.cookie = \"hgLogin_UserName=%s; domain=ucsc.edu; expires=Thu, 31 Dec 2099, 20:47:11 UTC; path=/\"; " "\n" "document.cookie = \"hgLogin_UserID=%d; domain=ucsc.edu; expires=Thu, 31 Dec 2099, 20:47:11 UTC; path=/\";" " </script>" "\n", userID, userName,userID); hPrintf( "<script language=\"JavaScript\">\n" "<!-- " "\n" /* delay for 5 seconds then go back to page X */ /* TODO: afterDelayBackTo("http....") */ -"window.setTimeout(afterDelay, 5000);\n" +"window.setTimeout(afterDelay, 1000);\n" "function afterDelay() {\n" -"window.location =\"http://hgwdev-chinhli.cse.ucsc.edu/cgi-bin/hgSession?hgS_doMainPage=1\";" +"window.location =\"http://%s/cgi-bin/hgSession?hgS_doMainPage=1\";" "\n}" "\n" "//-->" "\n" "</script>" -); +,hgLoginHost); } void displayLogoutSuccess() /* display logout success msg, and reset cookie */ { +char *hgLoginHost = hgLoginLinkHost(); + 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 */ /*******************************/ hPrintf( "<script language=\"JavaScript\">\n" "<!-- " "\n" /* delay for 5 seconds then go back to page X */ /* TODO: afterDelayBackTo("http....") */ -"window.setTimeout(afterDelay, 5000);\n" +"window.setTimeout(afterDelay, 1000);\n" "function afterDelay() {\n" -"window.location =\"http://hgwdev-chinhli.cse.ucsc.edu/cgi-bin/hgSession?hgS_doMainPage=1\";" +"window.location =\"http://%s/cgi-bin/hgSession?hgS_doMainPage=1\";" "\n}" "\n" "//-->" "\n" "</script>" -); +,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,""))