File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
src/main/java/br/com/leticiamangueira/todolist/user Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 46
46
<scope >runtime</scope >
47
47
</dependency >
48
48
49
+ <dependency >
50
+ <groupId >at.favre.lib</groupId >
51
+ <artifactId >bcrypt</artifactId >
52
+ <version >0.10.2</version >
53
+ </dependency >
54
+
49
55
<dependency >
50
56
<groupId >org.projectlombok</groupId >
51
57
<artifactId >lombok</artifactId >
Original file line number Diff line number Diff line change 8
8
import org .springframework .web .bind .annotation .RequestMapping ;
9
9
import org .springframework .web .bind .annotation .RestController ;
10
10
11
+ import at .favre .lib .crypto .bcrypt .BCrypt ;
12
+
11
13
@ RestController
12
14
@ RequestMapping ("/users" )
13
15
public class UserController {
@@ -24,6 +26,9 @@ public ResponseEntity create(@RequestBody UserModel userModel) {
24
26
return ResponseEntity .status (HttpStatus .BAD_REQUEST ).body ("Usuário já existe!" );
25
27
}
26
28
29
+ var passwordHashred = BCrypt .withDefaults ().hashToString (12 , userModel .getPassword ().toCharArray ());
30
+ userModel .setPassword (passwordHashred );
31
+
27
32
var userCreated = this .userRepository .save (userModel );
28
33
return ResponseEntity .status (HttpStatus .CREATED ).body (userCreated );
29
34
}
You can’t perform that action at this time.
0 commit comments