I'm trying to POST a registration form using a Semantic-UI Api (based on ajax). The problem is that, I'm getting an 403 error code response. I have no idea how to handle this issue.
Code below:
@Controller:
@Controller
@RequestMapping("/user/")
public class UserController {
private final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger(getClass());
// Registration
@RequestMapping(value = "register/", method = RequestMethod.POST)
@ResponseBody
public GenericResponse registerUserAccount(@Valid UserDTO user, HttpServletRequest request)
{
LOGGER.debug("Registration of account: ", user);
return new GenericResponse("success");
}
}
UserDTO domain class:
@PasswordMatches
public class UserDTO {
@NotNull
@NotEmpty
@Size(min = 1)
private String firstName;
@NotNull
@NotEmpty
@Size(min = 1)
private String lastName;
@ValidEmail
@NotNull
@NotEmpty
@Size(min = 1)
private String email;
@NotNull
@NotEmpty
@Size(min = 1)
private String password;
@NotNull
@NotEmpty
@Size(min = 1)
private String matchingPassword;
// ommited getters, setters etc.
}
.jsp (ommited unnecessary part):
$('.ui.form .submit.button')
.api({
url: '/PhotoAlbum/user/register/',
method : 'POST',
serializeForm: true,
beforeSend: function(settings) {
},
onSuccess: function(data) {
if(data.message == "success"){
window.location.href = "/PhotoAlbum/";
}
}
});
Form :
Apache Tomcat logs:
0:0:0:0:0:0:0:1 - - [09/Nov/2015:16:11:45 +0100] "POST /PhotoAlbum/user/register/ HTTP/1.1" 403 1192
0:0:0:0:0:0:0:1 - - [09/Nov/2015:16:11:45 +0100] "GET /PhotoAlbum/user/register/?firstName=John&lastName=McMann&email=jmac%40gmail.com&password=SomePass%401&matchingPassword=SomePass%401 HTTP/1.1" 200 6577
Thank you for help.