This repository was archived by the owner on Dec 19, 2022. It is now read-only.
File tree 4 files changed +17
-9
lines changed
src/main/java/com/scriptql/scriptqlapi
4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 1
1
package com .scriptql .scriptqlapi .controllers ;
2
2
3
3
import com .scriptql .scriptqlapi .services .UserService ;
4
- import com .scriptql .scriptqlapi .utils . entities .User ;
4
+ import com .scriptql .scriptqlapi .entities .User ;
5
5
import org .springframework .web .bind .annotation .RequestMapping ;
6
6
import org .springframework .web .bind .annotation .RestController ;
7
7
Original file line number Diff line number Diff line change 1
- package com .scriptql .scriptqlapi .utils . entities ;
1
+ package com .scriptql .scriptqlapi .entities ;
2
2
3
3
import lombok .Data ;
4
4
5
5
import javax .persistence .Entity ;
6
+ import javax .persistence .Id ;
6
7
import javax .persistence .Table ;
7
8
import javax .validation .constraints .NotEmpty ;
8
9
9
10
@ Data
10
11
@ Entity
11
- @ Table (name = "user" )
12
- public class User extends AbstractEntity {
12
+ @ Table (name = "users" )
13
+ public class User implements IEntity {
14
+
15
+ @ Id
16
+ private long id ;
13
17
14
18
@ NotEmpty
15
19
private String login ;
20
+
21
+ @ NotEmpty
16
22
private String name ;
17
23
18
24
@ NotEmpty
19
25
private String password ;
26
+ private String salt ;
20
27
21
28
}
Original file line number Diff line number Diff line change 1
1
package com .scriptql .scriptqlapi .repositories ;
2
2
3
- import com .scriptql .scriptqlapi .utils . entities .User ;
3
+ import com .scriptql .scriptqlapi .entities .User ;
4
4
5
5
import java .util .Optional ;
6
6
Original file line number Diff line number Diff line change 1
1
package com .scriptql .scriptqlapi .services ;
2
2
3
+ import com .scriptql .scriptqlapi .entities .User ;
3
4
import com .scriptql .scriptqlapi .repositories .UserRepository ;
4
5
import com .scriptql .scriptqlapi .utils .Snowflake ;
5
- import com .scriptql .scriptqlapi .utils .entities .User ;
6
6
import org .springframework .security .crypto .bcrypt .BCrypt ;
7
7
import org .springframework .stereotype .Service ;
8
8
9
+ import java .util .UUID ;
10
+
9
11
@ Service
10
12
public class UserService extends AbstractService <User > {
11
13
12
- private static final String SALT = "PAO DE BATATA COM AZEITONA" ;
13
-
14
14
public UserService (UserRepository repository , Snowflake snowflake ) {
15
15
super (repository , snowflake );
16
16
}
17
17
18
18
@ Override
19
19
public User create (User user ) {
20
- user .setPassword (BCrypt .hashpw (user .getPassword (), SALT ));
20
+ user .setSalt (UUID .randomUUID ().toString ().substring (0 , 25 ));
21
+ user .setPassword (BCrypt .hashpw (user .getPassword (), user .getSalt ()));
21
22
return super .create (user );
22
23
}
23
24
You can’t perform that action at this time.
0 commit comments