Skip to content

Commit 3a6163c

Browse files
committed
remove old registration
1 parent f6447e7 commit 3a6163c

7 files changed

Lines changed: 87 additions & 48 deletions

File tree

‎spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public MvcConfig() {
3636
public void addViewControllers(final ViewControllerRegistry registry) {
3737
super.addViewControllers(registry);
3838
registry.addViewController("/login.html");
39+
registry.addViewController("/registration.html");
3940
registry.addViewController("/logout.html");
4041
registry.addViewController("/homepage.html");
4142
registry.addViewController("/expiredAccount.html");

‎spring-security-login-and-registration/src/main/java/org/baeldung/web/controller/RegistrationController.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ public RegistrationController() {
6868
@ResponseBody
6969
public GenericResponse registerUserAccount(@Valid final UserDto accountDto, final HttpServletRequest request) {
7070
LOGGER.debug("Registering user account with information: {}", accountDto);
71-
// if (result.hasErrors()) {
72-
// return new GenericResponse(result.getFieldErrors(), result.getGlobalErrors());
73-
// }
71+
7472
final User registered = createUserAccount(accountDto);
7573
if (registered == null) {
7674
return new GenericResponse("email", messages.getMessage("message.regError", null, request.getLocale()));

‎spring-security-login-and-registration/src/main/webapp/WEB-INF/view/badUser.jsp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ code="label.badUser.title"></spring:message></title>
1717
${param.message}
1818
</h1>
1919
<br>
20-
<a href="<c:url value="/old/user/registration" />"><spring:message
20+
<a href="<c:url value="/registration.html" />"><spring:message
2121
code="label.form.loginSignUp"></spring:message></a>
2222

2323
<c:if test="${param.expired}">

‎spring-security-login-and-registration/src/main/webapp/WEB-INF/view/expiredAccount.jsp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<spring:message code="auth.message.expired"></spring:message>
1717
</h1>
1818
<br>
19-
<a href="<c:url value="/old/user/registration" />"><spring:message
19+
<a href="<c:url value="/registration.html" />"><spring:message
2020
code="label.form.loginSignUp"></spring:message></a>
2121

2222
</body>

‎spring-security-login-and-registration/src/main/webapp/WEB-INF/view/forgetPassword.jsp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</div>
3333

3434
<br>
35-
<a href="<c:url value="/old/user/registration" />"><spring:message code="label.form.loginSignUp"></spring:message></a>
35+
<a href="<c:url value="/registration.html" />"><spring:message code="label.form.loginSignUp"></spring:message></a>
3636
<br>
3737
<a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a>
3838

‎spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ${param.message}
9797

9898
</form>
9999
<br> Current Locale : ${pageContext.response.locale} <br> <a
100-
href="<c:url value="/old/user/registration" />"><spring:message
100+
href="<c:url value="/registration.html" />"><spring:message
101101
code="label.form.loginSignUp"></spring:message></a>
102102
<br><br><br>
103103
<a href="<c:url value="/forgetPassword.html" />"><spring:message
Lines changed: 81 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,95 @@
11
<!DOCTYPE html>
22
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
33
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4-
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
54
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
65
<%@ page session="false"%>
76
<html>
87
<head>
9-
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
8+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
109
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
1110
<title><spring:message code="label.form.title"></spring:message></title>
1211
</head>
1312
<body>
14-
<div class="container">
15-
<div class="span12">
16-
<h1>
17-
<spring:message code="label.form.title"></spring:message>
18-
</h1>
19-
<form:form modelAttribute="user" method="POST" enctype="utf8">
20-
<br>
21-
<tr>
22-
<td><label><spring:message code="label.user.firstName"></spring:message></label></td>
23-
<td><form:input path="firstName" value="" /></td>
24-
<form:errors path="firstName" cssClass="alert alert-error" element="div" />
25-
</tr>
26-
<tr>
27-
<td><label><spring:message code="label.user.lastName"></spring:message></label></td>
28-
<td><form:input path="lastName" value="" /></td>
29-
<form:errors path="lastName" cssClass="alert alert-error" element="div" />
30-
</tr>
31-
<tr>
32-
<td><label><spring:message code="label.user.email"></spring:message></label></td>
33-
<td><form:input path="email" value="" /></td>
34-
<form:errors path="email" cssClass="alert alert-error" element="div" />
35-
</tr>
36-
<tr>
37-
<td><label><spring:message code="label.user.password"></spring:message></label></td>
38-
<td><form:input path="password" value="" type="password" /></td>
39-
<form:errors path="password" cssClass="alert alert-error" element="div" />
40-
</tr>
41-
<tr>
42-
<td><label><spring:message code="label.user.confirmPass"></spring:message></label></td>
43-
<td><form:input path="matchingPassword" value="" type="password" /></td>
44-
<form:errors cssClass="alert alert-error" element="div" />
45-
</tr>
46-
<button type="submit" class="btn btn-primary">
47-
<spring:message code="label.form.submit"></spring:message>
48-
</button>
49-
</form:form>
50-
<br> <a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a>
51-
</div>
52-
</div>
13+
<div class="container">
14+
<div >
15+
<h1>
16+
<spring:message code="label.form.title"></spring:message>
17+
</h1>
18+
<br>
19+
<form action="/" method="POST" enctype="utf8">
20+
<div class="form-group row" >
21+
<label class="col-sm-3"><spring:message code="label.user.firstName"></spring:message></label>
22+
<span class="col-sm-5"><input class="form-control" name="firstName" value="" /></span>
23+
<span id="firstNameError" class="alert alert-danger col-sm-4" style="display:none"></span>
24+
25+
</div>
26+
<div class="form-group row">
27+
<label class="col-sm-3"><spring:message code="label.user.lastName"></spring:message></label>
28+
<span class="col-sm-5"><input class="form-control" name="lastName" value="" /></span>
29+
<span id="lastNameError" class="alert alert-danger col-sm-4" style="display:none"></span>
30+
31+
</div>
32+
<div class="form-group row">
33+
<label class="col-sm-3"><spring:message code="label.user.email"></spring:message></label>
34+
<span class="col-sm-5"><input class="form-control" name="email" value="" /></span>
35+
<span id="emailError" class="alert alert-danger col-sm-4" style="display:none"></span>
36+
37+
</div>
38+
<div class="form-group row">
39+
<label class="col-sm-3"><spring:message code="label.user.password"></spring:message></label>
40+
<span class="col-sm-5"><input class="form-control" name="password" value="" type="password" /></span>
41+
<span id="passwordError" class="alert alert-danger col-sm-4" style="display:none"></span>
42+
</div>
43+
<div class="form-group row">
44+
<label class="col-sm-3"><spring:message code="label.user.confirmPass"></spring:message></label>
45+
<span class="col-sm-5"><input class="form-control" name="matchingPassword" value="" type="password" /></span>
46+
<span id="globalError" class="alert alert-danger col-sm-4" style="display:none"></span>
47+
</div>
48+
<br>
49+
<a href="#" class="btn btn-primary" onclick="register()">
50+
<spring:message code="label.form.submit"></spring:message>
51+
</a>
52+
</form>
53+
<br>
54+
<a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a>
55+
</div>
56+
</div>
57+
58+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
59+
<script type="text/javascript">
60+
function register(){
61+
$(".alert").html("").hide();
62+
var formData= $('form').serialize();
63+
$.post("/spring-security-login-and-registration/user/registration",formData ,function(data){
64+
if(data.message == "success"){
65+
window.location.href = "<c:url value="/successRegister.html"></c:url>";
66+
}
67+
else if(data.message == "email"){
68+
$("#emailError").show().html(data.error);
69+
}
70+
else{
71+
72+
var errors = $.parseJSON(data.message);
73+
$.each( errors, function( index,item ){
74+
$("#"+item.field+"Error").show().html(item.defaultMessage);
75+
});
76+
errors = $.parseJSON(data.error);
77+
$.each( errors, function( index,item ){
78+
$("#globalError").show().append(item.defaultMessage+"<br>");
79+
});
80+
}
81+
})
82+
.fail(function(data) {
83+
if(data.responseJSON.error.indexOf("MailError") > -1)
84+
{
85+
window.location.href = "<c:url value="/emailError.html"></c:url>";
86+
}
87+
else{
88+
window.location.href = "<c:url value="/login.html"></c:url>" + "?message=" + data.responseJSON.message;
89+
}
90+
});
91+
}
92+
</script>
5393
</body>
5494

5595
</html>

0 commit comments

Comments
 (0)