Merge pull request #172 from Doha2012/master

remove old registration
This commit is contained in:
Eugen 2015-03-24 23:51:50 +02:00
commit 52ab94906d
7 changed files with 87 additions and 48 deletions

View File

@ -36,6 +36,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
public void addViewControllers(final ViewControllerRegistry registry) { public void addViewControllers(final ViewControllerRegistry registry) {
super.addViewControllers(registry); super.addViewControllers(registry);
registry.addViewController("/login.html"); registry.addViewController("/login.html");
registry.addViewController("/registration.html");
registry.addViewController("/logout.html"); registry.addViewController("/logout.html");
registry.addViewController("/homepage.html"); registry.addViewController("/homepage.html");
registry.addViewController("/expiredAccount.html"); registry.addViewController("/expiredAccount.html");

View File

@ -68,9 +68,7 @@ public class RegistrationController {
@ResponseBody @ResponseBody
public GenericResponse registerUserAccount(@Valid final UserDto accountDto, final HttpServletRequest request) { public GenericResponse registerUserAccount(@Valid final UserDto accountDto, final HttpServletRequest request) {
LOGGER.debug("Registering user account with information: {}", accountDto); LOGGER.debug("Registering user account with information: {}", accountDto);
// if (result.hasErrors()) {
// return new GenericResponse(result.getFieldErrors(), result.getGlobalErrors());
// }
final User registered = createUserAccount(accountDto); final User registered = createUserAccount(accountDto);
if (registered == null) { if (registered == null) {
return new GenericResponse("email", messages.getMessage("message.regError", null, request.getLocale())); return new GenericResponse("email", messages.getMessage("message.regError", null, request.getLocale()));

View File

@ -17,7 +17,7 @@ code="label.badUser.title"></spring:message></title>
${param.message} ${param.message}
</h1> </h1>
<br> <br>
<a href="<c:url value="/old/user/registration" />"><spring:message <a href="<c:url value="/registration.html" />"><spring:message
code="label.form.loginSignUp"></spring:message></a> code="label.form.loginSignUp"></spring:message></a>
<c:if test="${param.expired}"> <c:if test="${param.expired}">

View File

@ -16,7 +16,7 @@
<spring:message code="auth.message.expired"></spring:message> <spring:message code="auth.message.expired"></spring:message>
</h1> </h1>
<br> <br>
<a href="<c:url value="/old/user/registration" />"><spring:message <a href="<c:url value="/registration.html" />"><spring:message
code="label.form.loginSignUp"></spring:message></a> code="label.form.loginSignUp"></spring:message></a>
</body> </body>

View File

@ -32,7 +32,7 @@
</div> </div>
<br> <br>
<a href="<c:url value="/old/user/registration" />"><spring:message code="label.form.loginSignUp"></spring:message></a> <a href="<c:url value="/registration.html" />"><spring:message code="label.form.loginSignUp"></spring:message></a>
<br> <br>
<a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a> <a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a>

View File

@ -97,7 +97,7 @@ ${param.message}
</form> </form>
<br> Current Locale : ${pageContext.response.locale} <br> <a <br> Current Locale : ${pageContext.response.locale} <br> <a
href="<c:url value="/old/user/registration" />"><spring:message href="<c:url value="/registration.html" />"><spring:message
code="label.form.loginSignUp"></spring:message></a> code="label.form.loginSignUp"></spring:message></a>
<br><br><br> <br><br><br>
<a href="<c:url value="/forgetPassword.html" />"><spring:message <a href="<c:url value="/forgetPassword.html" />"><spring:message

View File

@ -1,55 +1,95 @@
<!DOCTYPE html> <!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java"%> <%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ page session="false"%> <%@ page session="false"%>
<html> <html>
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title><spring:message code="label.form.title"></spring:message></title> <title><spring:message code="label.form.title"></spring:message></title>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="span12"> <div >
<h1> <h1>
<spring:message code="label.form.title"></spring:message> <spring:message code="label.form.title"></spring:message>
</h1> </h1>
<form:form modelAttribute="user" method="POST" enctype="utf8"> <br>
<br> <form action="/" method="POST" enctype="utf8">
<tr> <div class="form-group row" >
<td><label><spring:message code="label.user.firstName"></spring:message></label></td> <label class="col-sm-3"><spring:message code="label.user.firstName"></spring:message></label>
<td><form:input path="firstName" value="" /></td> <span class="col-sm-5"><input class="form-control" name="firstName" value="" /></span>
<form:errors path="firstName" cssClass="alert alert-error" element="div" /> <span id="firstNameError" class="alert alert-danger col-sm-4" style="display:none"></span>
</tr>
<tr> </div>
<td><label><spring:message code="label.user.lastName"></spring:message></label></td> <div class="form-group row">
<td><form:input path="lastName" value="" /></td> <label class="col-sm-3"><spring:message code="label.user.lastName"></spring:message></label>
<form:errors path="lastName" cssClass="alert alert-error" element="div" /> <span class="col-sm-5"><input class="form-control" name="lastName" value="" /></span>
</tr> <span id="lastNameError" class="alert alert-danger col-sm-4" style="display:none"></span>
<tr>
<td><label><spring:message code="label.user.email"></spring:message></label></td> </div>
<td><form:input path="email" value="" /></td> <div class="form-group row">
<form:errors path="email" cssClass="alert alert-error" element="div" /> <label class="col-sm-3"><spring:message code="label.user.email"></spring:message></label>
</tr> <span class="col-sm-5"><input class="form-control" name="email" value="" /></span>
<tr> <span id="emailError" class="alert alert-danger col-sm-4" style="display:none"></span>
<td><label><spring:message code="label.user.password"></spring:message></label></td>
<td><form:input path="password" value="" type="password" /></td> </div>
<form:errors path="password" cssClass="alert alert-error" element="div" /> <div class="form-group row">
</tr> <label class="col-sm-3"><spring:message code="label.user.password"></spring:message></label>
<tr> <span class="col-sm-5"><input class="form-control" name="password" value="" type="password" /></span>
<td><label><spring:message code="label.user.confirmPass"></spring:message></label></td> <span id="passwordError" class="alert alert-danger col-sm-4" style="display:none"></span>
<td><form:input path="matchingPassword" value="" type="password" /></td> </div>
<form:errors cssClass="alert alert-error" element="div" /> <div class="form-group row">
</tr> <label class="col-sm-3"><spring:message code="label.user.confirmPass"></spring:message></label>
<button type="submit" class="btn btn-primary"> <span class="col-sm-5"><input class="form-control" name="matchingPassword" value="" type="password" /></span>
<spring:message code="label.form.submit"></spring:message> <span id="globalError" class="alert alert-danger col-sm-4" style="display:none"></span>
</button> </div>
</form:form> <br>
<br> <a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a> <a href="#" class="btn btn-primary" onclick="register()">
</div> <spring:message code="label.form.submit"></spring:message>
</div> </a>
</form>
<br>
<a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
function register(){
$(".alert").html("").hide();
var formData= $('form').serialize();
$.post("/spring-security-login-and-registration/user/registration",formData ,function(data){
if(data.message == "success"){
window.location.href = "<c:url value="/successRegister.html"></c:url>";
}
else if(data.message == "email"){
$("#emailError").show().html(data.error);
}
else{
var errors = $.parseJSON(data.message);
$.each( errors, function( index,item ){
$("#"+item.field+"Error").show().html(item.defaultMessage);
});
errors = $.parseJSON(data.error);
$.each( errors, function( index,item ){
$("#globalError").show().append(item.defaultMessage+"<br>");
});
}
})
.fail(function(data) {
if(data.responseJSON.error.indexOf("MailError") > -1)
{
window.location.href = "<c:url value="/emailError.html"></c:url>";
}
else{
window.location.href = "<c:url value="/login.html"></c:url>" + "?message=" + data.responseJSON.message;
}
});
}
</script>
</body> </body>
</html> </html>