szerhusenBC / jwt-spring-security-demo

A demo for using JWT (Json Web Token) with Spring Security and Spring Boot 2
MIT License
3.04k stars 1.33k forks source link

Save new user #114

Open ricardogusi opened 3 years ago

ricardogusi commented 3 years ago

Hi, first of all thank you so much for this application. Sorry about the "silly" question but how do I register a new user? I've created this: @PostMapping("/register") public ResponseEntity saveUser(@RequestBody User user) { return ResponseEntity.ok(repository.save(user));

}

and on postaman for example tried this:

{
"username": "ricardo", "password": "123456", "firstname": "Ricardo", "lastname": "Gusi", "email": "ricardo@email", "activated" : "1"
}

but I get this:

"message": "Validation failed for classes [org.zerhusen.security.model.User] during persist time for groups [javax.validation.groups.Default, ]\nList of constraint violations:[\n\tConstraintViolationImpl{interpolatedMessage='não pode ser nulo', propertyPath=password, rootBeanClass=class org.zerhusen.security.model.User, messageTemplate='{javax.validation.constraints.NotNull.message}'}\n]",