add admin register
This commit is contained in:
parent
85cc2ef8f8
commit
1207d4a8c4
|
@ -1,155 +1,162 @@
|
|||
package org.bench4q.web.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.communication.HttpRequester;
|
||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.share.models.master.AuthorizeResponseModel;
|
||||
import org.bench4q.share.models.master.RegisterResponseModel;
|
||||
import org.bench4q.share.models.master.UserModel;
|
||||
import org.bench4q.web.exception.CustomGenericException;
|
||||
import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
|
||||
import org.bench4q.web.model.BaseResponseModel;
|
||||
import org.bench4q.web.model.TestPlanTaskModel;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
@Controller
|
||||
@SessionAttributes({ "accessToken", "username", "testPlanTaskList" })
|
||||
public class AuthorizeActionController extends BaseControllerService {
|
||||
private Logger logger = Logger.getLogger(AuthorizeActionController.class);
|
||||
private String baseUrl = this.masterIp + "user";
|
||||
private String INVALIDATE_INPUT = "invalidate input";
|
||||
|
||||
@RequestMapping("login")
|
||||
public @ResponseBody
|
||||
BaseResponseModel login(UserModel user, ModelMap model)
|
||||
throws CustomGenericException {
|
||||
isValidate(user);
|
||||
AuthorizeResponseModel authorizeResponseModel = authorize(baseUrl
|
||||
+ "/normalAuthorize", user);
|
||||
return extractAuthorizeResponseModel(authorizeResponseModel, user,
|
||||
model);
|
||||
}
|
||||
|
||||
@RequestMapping("adminLogin")
|
||||
public @ResponseBody
|
||||
BaseResponseModel adminLogin(UserModel user, ModelMap model)
|
||||
throws CustomGenericException {
|
||||
isValidate(user);
|
||||
|
||||
AuthorizeResponseModel authorizeResponseModel = authorize(baseUrl
|
||||
+ "/adminAuthorize", user);
|
||||
return extractAuthorizeResponseModel(authorizeResponseModel, user,
|
||||
model);
|
||||
}
|
||||
|
||||
@RequestMapping("register")
|
||||
@ResponseBody
|
||||
public BaseResponseModel register(UserModel user)
|
||||
throws CustomGenericException {
|
||||
System.out.println("enter register!!");
|
||||
isValidate(user);
|
||||
Map<String, String> params = this.makeParamsMap("userName",
|
||||
user.getUserName());
|
||||
params.put("password", user.getPassword());
|
||||
try {
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
||||
baseUrl + "/register", params, null);
|
||||
if (HttpRequester.isInvalidResponse(httpResponse)) {
|
||||
throw new CustomGenericException("0",
|
||||
"invalidate httpResponse",
|
||||
"AuthorizeActionController_register");
|
||||
}
|
||||
RegisterResponseModel registerResponseModel = (RegisterResponseModel) ObjectXmlExchange
|
||||
.fromXml(RegisterResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
return extractRegisterModel(registerResponseModel);
|
||||
} catch (IOException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpresponse:io exception", this.baseUrl
|
||||
+ "/register");
|
||||
} catch (JAXBException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpresponse:JAXBException", this.baseUrl
|
||||
+ "/register");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private AuthorizeResponseModel authorize(String url, UserModel user)
|
||||
throws CustomGenericException {
|
||||
try {
|
||||
Map<String, String> params = this.makeParamsMap("userName",
|
||||
user.getUserName());
|
||||
params.put("password", user.getPassword());
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(url,
|
||||
params, null);
|
||||
if (HttpRequester.isInvalidResponse(httpResponse)) {
|
||||
throw new CustomGenericException("1", "network error:",
|
||||
"AuthorizeActionController_authorize");
|
||||
}
|
||||
|
||||
return (AuthorizeResponseModel) ObjectXmlExchange.fromXml(
|
||||
AuthorizeResponseModel.class, httpResponse.getContent());
|
||||
} catch (IOException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpResponse:IOException",
|
||||
"AuthorizeActionController_authorize");
|
||||
} catch (JAXBException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpResponse:JAXBException",
|
||||
"AuthorizeActionController_authorize");
|
||||
}
|
||||
}
|
||||
|
||||
private BaseResponseModel extractAuthorizeResponseModel(
|
||||
AuthorizeResponseModel authorizeResponseModel, UserModel user,
|
||||
ModelMap model) {
|
||||
|
||||
if (!authorizeResponseModel.isSuccess()) {
|
||||
logger.info("user name:" + user.getUserName());
|
||||
logger.info("user password:" + user.getPassword());
|
||||
logger.info("password or name wrong");
|
||||
return new BaseResponseModel(false, "password or name wrong!");
|
||||
} else {
|
||||
model.addAttribute("accessToken",
|
||||
authorizeResponseModel.getAccessToken());
|
||||
model.addAttribute("username", user.getUserName());
|
||||
List<TestPlanTaskModel> testPlanTaskModels = new ArrayList<TestPlanTaskModel>();
|
||||
model.addAttribute("testPlanTaskList", testPlanTaskModels);
|
||||
return new BaseResponseModel(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BaseResponseModel extractRegisterModel(
|
||||
RegisterResponseModel registerResponseModel) {
|
||||
|
||||
if (registerResponseModel.isSuccess())
|
||||
return new BaseResponseModel(true);
|
||||
|
||||
else
|
||||
return new BaseResponseModel(false, "");
|
||||
}
|
||||
|
||||
private void isValidate(UserModel user) throws CustomGenericException {
|
||||
if (user.getPassword() == null || user.getUserName() == null
|
||||
|| user.getPassword().equals("")
|
||||
|| user.getUserName().equals(""))
|
||||
throw new CustomGenericException("0", INVALIDATE_INPUT, "");
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.web.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.communication.HttpRequester;
|
||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.share.models.master.AuthorizeResponseModel;
|
||||
import org.bench4q.share.models.master.RegisterResponseModel;
|
||||
import org.bench4q.share.models.master.UserModel;
|
||||
import org.bench4q.web.exception.CustomGenericException;
|
||||
import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
|
||||
import org.bench4q.web.model.BaseResponseModel;
|
||||
import org.bench4q.web.model.TestPlanTaskModel;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
@Controller
|
||||
@SessionAttributes({ "accessToken", "username", "testPlanTaskList" })
|
||||
public class AuthorizeActionController extends BaseControllerService {
|
||||
private Logger logger = Logger.getLogger(AuthorizeActionController.class);
|
||||
private String baseUrl = this.masterIp + "user";
|
||||
private String INVALIDATE_INPUT = "invalidate input";
|
||||
|
||||
@RequestMapping("login")
|
||||
public @ResponseBody
|
||||
BaseResponseModel login(UserModel user, ModelMap model)
|
||||
throws CustomGenericException {
|
||||
isValidate(user);
|
||||
AuthorizeResponseModel authorizeResponseModel = authorize(baseUrl
|
||||
+ "/normalAuthorize", user);
|
||||
return extractAuthorizeResponseModel(authorizeResponseModel, user,
|
||||
model);
|
||||
}
|
||||
|
||||
@RequestMapping("adminLogin")
|
||||
public @ResponseBody
|
||||
BaseResponseModel adminLogin(UserModel user, ModelMap model)
|
||||
throws CustomGenericException {
|
||||
isValidate(user);
|
||||
|
||||
AuthorizeResponseModel authorizeResponseModel = authorize(baseUrl
|
||||
+ "/adminAuthorize", user);
|
||||
return extractAuthorizeResponseModel(authorizeResponseModel, user,
|
||||
model);
|
||||
}
|
||||
|
||||
@RequestMapping("register")
|
||||
@ResponseBody
|
||||
public BaseResponseModel register(@RequestParam String userName,
|
||||
@RequestParam String password,
|
||||
@RequestParam String scope) throws CustomGenericException {
|
||||
UserModel user = new UserModel();
|
||||
user.setUserName(userName);
|
||||
user.setPassword(password);
|
||||
isValidate(user);
|
||||
Map<String, String> params = this.makeParamsMap("userName",
|
||||
user.getUserName());
|
||||
params.put("password", user.getPassword());
|
||||
params.put("scope", scope);
|
||||
try {
|
||||
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
||||
baseUrl + "/register", params, null);
|
||||
if (HttpRequester.isInvalidResponse(httpResponse)) {
|
||||
throw new CustomGenericException("0",
|
||||
"invalidate httpResponse",
|
||||
"AuthorizeActionController_register");
|
||||
}
|
||||
RegisterResponseModel registerResponseModel = (RegisterResponseModel) ObjectXmlExchange
|
||||
.fromXml(RegisterResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
return extractRegisterModel(registerResponseModel);
|
||||
} catch (IOException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpresponse:io exception", this.baseUrl
|
||||
+ "/register");
|
||||
} catch (JAXBException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpresponse:JAXBException", this.baseUrl
|
||||
+ "/register");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private AuthorizeResponseModel authorize(String url, UserModel user)
|
||||
throws CustomGenericException {
|
||||
try {
|
||||
Map<String, String> params = this.makeParamsMap("userName",
|
||||
user.getUserName());
|
||||
params.put("password", user.getPassword());
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(url,
|
||||
params, null);
|
||||
if (HttpRequester.isInvalidResponse(httpResponse)) {
|
||||
throw new CustomGenericException("1", "network error:",
|
||||
"AuthorizeActionController_authorize");
|
||||
}
|
||||
|
||||
return (AuthorizeResponseModel) ObjectXmlExchange.fromXml(
|
||||
AuthorizeResponseModel.class, httpResponse.getContent());
|
||||
} catch (IOException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpResponse:IOException",
|
||||
"AuthorizeActionController_authorize");
|
||||
} catch (JAXBException e) {
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpResponse:JAXBException",
|
||||
"AuthorizeActionController_authorize");
|
||||
}
|
||||
}
|
||||
|
||||
private BaseResponseModel extractAuthorizeResponseModel(
|
||||
AuthorizeResponseModel authorizeResponseModel, UserModel user,
|
||||
ModelMap model) {
|
||||
|
||||
if (!authorizeResponseModel.isSuccess()) {
|
||||
logger.info("user name:" + user.getUserName());
|
||||
logger.info("user password:" + user.getPassword());
|
||||
logger.info("password or name wrong");
|
||||
return new BaseResponseModel(false, "password or name wrong!");
|
||||
} else {
|
||||
model.addAttribute("accessToken",
|
||||
authorizeResponseModel.getAccessToken());
|
||||
model.addAttribute("username", user.getUserName());
|
||||
List<TestPlanTaskModel> testPlanTaskModels = new ArrayList<TestPlanTaskModel>();
|
||||
model.addAttribute("testPlanTaskList", testPlanTaskModels);
|
||||
return new BaseResponseModel(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BaseResponseModel extractRegisterModel(
|
||||
RegisterResponseModel registerResponseModel) {
|
||||
|
||||
if (registerResponseModel.isSuccess())
|
||||
return new BaseResponseModel(true);
|
||||
|
||||
else
|
||||
return new BaseResponseModel(false, "");
|
||||
}
|
||||
|
||||
private void isValidate(UserModel user) throws CustomGenericException {
|
||||
if (user.getPassword() == null || user.getUserName() == null
|
||||
|| user.getPassword().equals("")
|
||||
|| user.getUserName().equals(""))
|
||||
throw new CustomGenericException("0", INVALIDATE_INPUT, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
.registerContainer {
|
||||
background-color: #efefef;
|
||||
padding-top: 80px;
|
||||
padding-left: 20px;
|
||||
padding-bottom: 50px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.bench4qLog {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.tipContainer {
|
||||
height: 50px;
|
||||
width: 50%;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.registerInput {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.userInput {
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
input {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.submitDiv {
|
||||
float: left;
|
||||
margin-right: 50px;
|
||||
.registerContainer {
|
||||
background-color: #efefef;
|
||||
padding-top: 80px;
|
||||
padding-left: 20px;
|
||||
padding-bottom: 50px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.bench4qLog {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.tipContainer {
|
||||
height: 50px;
|
||||
width: 50%;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.registerInput {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.userInput {
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
input {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.submitDiv {
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
}
|
|
@ -1,104 +1,111 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<link rel="shortcut icon" href="images/bench4q.png">
|
||||
<link href="lib/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="lib/github/css/github-6053501db2b69fd2b04652c6349117be14468ce4.css"
|
||||
media="screen" rel="stylesheet">
|
||||
<link href="css/index.css" media="screen" rel="stylesheet">
|
||||
<link href="css/register.css" media="screen" rel="stylesheet">
|
||||
<link rel="shortcut icon" href="images/bench4q.png">
|
||||
<style type="text/css">
|
||||
/* body {
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
.sidebar-nav {
|
||||
padding: 9px 0;
|
||||
} */
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header" class="true clearfix" style="height: 50px">
|
||||
<div class="container clearfix">
|
||||
<a class="site-logo" href="index.jsp"><img id="bench4q"
|
||||
src="images/headerLogo.png" height="30" /></a>
|
||||
<ul class="top-nav logged_out">
|
||||
<li class="login"><a href="login.jsp"><fmt:message
|
||||
key="index_jsp_login" /></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>
|
||||
<fmt:message key="index_jsp_Title" />
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="registerContainer">
|
||||
<div class="left ">
|
||||
<div class="tipContainer">
|
||||
<img src="images/tips.jpg" />
|
||||
</div>
|
||||
<div class="userInput">
|
||||
<div class="registerInput row-fluid">
|
||||
<img alt="bench4q-username" src="images/username.jpg"><span> UserName: </span>
|
||||
<input autofocus id="username" name="username" tabindex="1" type="text"
|
||||
onchange="form_validation('username')">
|
||||
</div>
|
||||
<div class="hide">
|
||||
<img src="images/error.jpg"> <span>the username must
|
||||
be 5-20 letters or numbers</span>
|
||||
</div>
|
||||
<div class="registerInput row-fluid">
|
||||
<img alt="bench4q-password" src="images/password.jpg"><span> Password: </span>
|
||||
<input id="password" name="password" tabindex="1" type="password"
|
||||
onchange="form_validation('password')">
|
||||
</div>
|
||||
<div class="hide">
|
||||
<img src="images/error.jpg"> <span>the password must
|
||||
be 6-20 letters or numbers </span>
|
||||
</div>
|
||||
<div class="registerInput row-fluid">
|
||||
<img alt="bench4q-retype-password" src="images/retype.jpg"><span> Re-Password:
|
||||
</span> <input id="retype_pwd" name="retype_pwd" tabindex="1" type="password"
|
||||
onchange="form_validation('retype_pwd')">
|
||||
</div>
|
||||
<div class="hide">
|
||||
<img src="images/error.jpg"> <span>the
|
||||
retype-password is wrong</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="submitDiv">
|
||||
<input type="image" name="Submit" value="Register"
|
||||
src="images/submit.jpg"
|
||||
onMouseOver="this.src='images/submiton.jpg'"
|
||||
onMouseOut="this.src='images/submit.jpg'"
|
||||
onClick="javascript:password_validation();return false" />
|
||||
</div>
|
||||
<div class="submitDiv">
|
||||
<img name="Clear" src="images/clear.jpg"
|
||||
onMouseOver="this.src='images/clearon.jpg'"
|
||||
onMouseOut="this.src='images/clear.jpg'"
|
||||
onClick="javascript:clean();return false" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="bench4qLog">
|
||||
<img src="images/bench4qblog.jpg" />
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- for scripts -->
|
||||
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
|
||||
<script src="script/register.js"></script>
|
||||
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<link rel="shortcut icon" href="images/bench4q.png">
|
||||
<link href="lib/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="lib/github/css/github-6053501db2b69fd2b04652c6349117be14468ce4.css"
|
||||
media="screen" rel="stylesheet">
|
||||
<link href="css/index.css" media="screen" rel="stylesheet">
|
||||
<link href="css/register.css" media="screen" rel="stylesheet">
|
||||
<link rel="shortcut icon" href="images/bench4q.png">
|
||||
<style type="text/css">
|
||||
/* body {
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
.sidebar-nav {
|
||||
padding: 9px 0;
|
||||
} */
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header" class="true clearfix" style="height: 50px">
|
||||
<div class="container clearfix">
|
||||
<a class="site-logo" href="index.jsp"><img id="bench4q"
|
||||
src="images/headerLogo.png" height="30" /></a>
|
||||
<ul class="top-nav logged_out">
|
||||
<li class="login"><a href="login.jsp"><fmt:message
|
||||
key="index_jsp_login" /></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>
|
||||
<fmt:message key="index_jsp_Title" />
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="registerContainer">
|
||||
<div class="left ">
|
||||
<div class="tipContainer">
|
||||
<img src="images/tips.jpg" />
|
||||
</div>
|
||||
<div class="userInput">
|
||||
<div class="registerInput row-fluid">
|
||||
<img alt="bench4q-username" src="images/username.jpg"><span> UserName: </span>
|
||||
<input autofocus id="username" name="username" tabindex="1" type="text"
|
||||
onchange="form_validation('username')">
|
||||
</div>
|
||||
<div class="hide">
|
||||
<img src="images/error.jpg"> <span>the username must
|
||||
be 5-20 letters or numbers</span>
|
||||
</div>
|
||||
<div class="registerInput row-fluid">
|
||||
<img alt="bench4q-password" src="images/password.jpg"><span> Password: </span>
|
||||
<input id="password" name="password" tabindex="1" type="password"
|
||||
onchange="form_validation('password')">
|
||||
</div>
|
||||
<div class="hide">
|
||||
<img src="images/error.jpg"> <span>the password must
|
||||
be 6-20 letters or numbers </span>
|
||||
</div>
|
||||
<div class="registerInput row-fluid">
|
||||
<img alt="bench4q-retype-password" src="images/retype.jpg"><span> Re-Password:
|
||||
</span> <input id="retype_pwd" name="retype_pwd" tabindex="1" type="password"
|
||||
onchange="form_validation('retype_pwd')">
|
||||
</div>
|
||||
<div class="hide">
|
||||
<img src="images/error.jpg"> <span>the
|
||||
retype-password is wrong</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="submitDiv">
|
||||
<input type="image" name="Submit" value="Register"
|
||||
src="images/submit.jpg"
|
||||
onMouseOver="this.src='images/submiton.jpg'"
|
||||
onMouseOut="this.src='images/submit.jpg'"
|
||||
onClick="javascript:password_validation(0);return false" />
|
||||
</div>
|
||||
<div class="submitDiv">
|
||||
<input type="image" name="Submit" value="Register"
|
||||
src="images/submit.jpg"
|
||||
onMouseOver="this.src='images/submiton.jpg'"
|
||||
onMouseOut="this.src='images/submit.jpg'"
|
||||
onClick="javascript:password_validation(1);return false" />
|
||||
</div>
|
||||
<div class="submitDiv">
|
||||
<img name="Clear" src="images/clear.jpg"
|
||||
onMouseOver="this.src='images/clearon.jpg'"
|
||||
onMouseOut="this.src='images/clear.jpg'"
|
||||
onClick="javascript:clean();return false" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="bench4qLog">
|
||||
<img src="images/bench4qblog.jpg" />
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- for scripts -->
|
||||
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
|
||||
<script src="script/register.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,85 +1,86 @@
|
|||
function form_validation(name) {
|
||||
var input_value = document.getElementsByName(name)[0].value;
|
||||
var regx = /^[a-zA-Z0-9]+$/;
|
||||
if (!regx.test(input_value)) {
|
||||
alert(name + " must be number!");
|
||||
if (name == "username") {
|
||||
$('#usrmsg').show();
|
||||
document.getElementsByName('username')[0].value = "";
|
||||
document.getElementsByName('username')[0].style.border = "1px solid red";
|
||||
}
|
||||
|
||||
else if (name == "password") {
|
||||
$('#pwdmsg').show();
|
||||
document.getElementsByName('password')[0].value = "";
|
||||
document.getElementsByName('password')[0].style.border = "1px solid red";
|
||||
}
|
||||
} else {
|
||||
document.getElementsByName(name)[0].style.border = "1px solid #ddd";
|
||||
if (name == "username")
|
||||
$('#usrmsg').hide();
|
||||
else if (name == "password")
|
||||
$('#pwdmsg').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function clean() {
|
||||
document.getElementsByName('username')[0].value = "";
|
||||
document.getElementsByName('password')[0].value = "";
|
||||
document.getElementsByName('retype_pwd')[0].value = "";
|
||||
}
|
||||
function register() {
|
||||
var userName = $('#username').val();
|
||||
var password = $('#password').val();
|
||||
var rePassword = $("#retype_pwd").val();
|
||||
$.post('register', {
|
||||
userName : userName,
|
||||
password : password,
|
||||
rePassword : rePassword
|
||||
}, function(data) {
|
||||
if (data.success) {
|
||||
window.location.replace("registerSuccess.jsp");
|
||||
} else {
|
||||
alert(data.failedMessage);
|
||||
// $('#registerMsg').html($.i18n.prop('msgRegister'));
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
|
||||
function password_validation() {
|
||||
var null_flag = 0;
|
||||
var user_name = document.getElementsByName('username')[0].value;
|
||||
var retype_pwd = document.getElementsByName('retype_pwd')[0].value;
|
||||
var input_pwd = document.getElementsByName('password')[0].value;
|
||||
|
||||
if (user_name == "") {
|
||||
$('#usrmsg').show();
|
||||
document.getElementsByName('username')[0].value = "";
|
||||
document.getElementsByName('username')[0].style.border = "1px solid red";
|
||||
null_flag = 1;
|
||||
} else {
|
||||
$('#usrmsg').hide();
|
||||
document.getElementsByName('username')[0].style.border = "";
|
||||
}
|
||||
|
||||
if (input_pwd == "") {
|
||||
$('#pwdmsg').show();
|
||||
document.getElementsByName('password')[0].value = "";
|
||||
document.getElementsByName('password')[0].style.border = "1px solid red";
|
||||
null_flag = 1;
|
||||
} else {
|
||||
$('#pwdmsg').hide();
|
||||
document.getElementsByName('password')[0].style.border = "";
|
||||
}
|
||||
if (input_pwd != retype_pwd) {
|
||||
$('#rtpmsg').show();
|
||||
document.getElementsByName('retype_pwd')[0].value = "";
|
||||
document.getElementsByName('retype_pwd')[0].style.border = "1px solid red";
|
||||
null_flag = 1;
|
||||
} else {
|
||||
$('#rtpmsg').hide();
|
||||
document.getElementsByName('retype_pwd')[0].style.border = "";
|
||||
}
|
||||
if (null_flag == 0)
|
||||
register();
|
||||
function form_validation(name) {
|
||||
var input_value = document.getElementsByName(name)[0].value;
|
||||
var regx = /^[a-zA-Z0-9]+$/;
|
||||
if (!regx.test(input_value)) {
|
||||
alert(name + " must be number!");
|
||||
if (name == "username") {
|
||||
$('#usrmsg').show();
|
||||
document.getElementsByName('username')[0].value = "";
|
||||
document.getElementsByName('username')[0].style.border = "1px solid red";
|
||||
}
|
||||
|
||||
else if (name == "password") {
|
||||
$('#pwdmsg').show();
|
||||
document.getElementsByName('password')[0].value = "";
|
||||
document.getElementsByName('password')[0].style.border = "1px solid red";
|
||||
}
|
||||
} else {
|
||||
document.getElementsByName(name)[0].style.border = "1px solid #ddd";
|
||||
if (name == "username")
|
||||
$('#usrmsg').hide();
|
||||
else if (name == "password")
|
||||
$('#pwdmsg').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function clean() {
|
||||
document.getElementsByName('username')[0].value = "";
|
||||
document.getElementsByName('password')[0].value = "";
|
||||
document.getElementsByName('retype_pwd')[0].value = "";
|
||||
}
|
||||
function register(scope) {
|
||||
alert(scope)
|
||||
var userName = $('#username').val();
|
||||
var password = $('#password').val();
|
||||
var rePassword = $("#retype_pwd").val();
|
||||
$.post('register', {
|
||||
userName : userName,
|
||||
password : password,
|
||||
scope:scope
|
||||
}, function(data) {
|
||||
if (data.success) {
|
||||
window.location.replace("registerSuccess.jsp");
|
||||
} else {
|
||||
alert(data.failedMessage);
|
||||
// $('#registerMsg').html($.i18n.prop('msgRegister'));
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
|
||||
function password_validation(scope) {
|
||||
var null_flag = 0;
|
||||
var user_name = document.getElementsByName('username')[0].value;
|
||||
var retype_pwd = document.getElementsByName('retype_pwd')[0].value;
|
||||
var input_pwd = document.getElementsByName('password')[0].value;
|
||||
|
||||
if (user_name == "") {
|
||||
$('#usrmsg').show();
|
||||
document.getElementsByName('username')[0].value = "";
|
||||
document.getElementsByName('username')[0].style.border = "1px solid red";
|
||||
null_flag = 1;
|
||||
} else {
|
||||
$('#usrmsg').hide();
|
||||
document.getElementsByName('username')[0].style.border = "";
|
||||
}
|
||||
|
||||
if (input_pwd == "") {
|
||||
$('#pwdmsg').show();
|
||||
document.getElementsByName('password')[0].value = "";
|
||||
document.getElementsByName('password')[0].style.border = "1px solid red";
|
||||
null_flag = 1;
|
||||
} else {
|
||||
$('#pwdmsg').hide();
|
||||
document.getElementsByName('password')[0].style.border = "";
|
||||
}
|
||||
if (input_pwd != retype_pwd) {
|
||||
$('#rtpmsg').show();
|
||||
document.getElementsByName('retype_pwd')[0].value = "";
|
||||
document.getElementsByName('retype_pwd')[0].style.border = "1px solid red";
|
||||
null_flag = 1;
|
||||
} else {
|
||||
$('#rtpmsg').hide();
|
||||
document.getElementsByName('retype_pwd')[0].style.border = "";
|
||||
}
|
||||
if (null_flag == 0)
|
||||
register(scope);
|
||||
}
|
Loading…
Reference in New Issue