|
1 | 1 | package com.example.auction.user.impl;
|
2 | 2 |
|
3 |
| -import com.fasterxml.jackson.annotation.JsonCreator; |
4 | 3 | import com.lightbend.lagom.javadsl.persistence.PersistentEntity;
|
5 | 4 | import com.lightbend.lagom.serialization.Jsonable;
|
6 | 5 | import lombok.Value;
|
|
10 | 9 |
|
11 | 10 | public interface PUserCommand extends Jsonable {
|
12 | 11 | @Value
|
13 |
| - final class CreatePUser implements PUserCommand, PersistentEntity.ReplyType<PUser> { |
| 12 | + final class CreatePUser implements PUserCommand, PersistentEntity.ReplyType<Optional<PUser>> { |
14 | 13 | private final String name;
|
15 | 14 | private final String email;
|
16 | 15 | private final String passwordHash;
|
17 | 16 | }
|
18 |
| - public static String hashPassword(String password_plaintext) { |
19 |
| - String salt = BCrypt.gensalt(12); |
20 |
| - String hashed_password = BCrypt.hashpw(password_plaintext, salt); |
21 | 17 |
|
22 |
| - return (hashed_password); |
23 |
| - } |
| 18 | + public static String hashPassword(String password_plaintext) { |
| 19 | + String salt = BCrypt.gensalt(12); |
| 20 | + String hashed_password = BCrypt.hashpw(password_plaintext, salt); |
24 | 21 |
|
25 |
| - public static boolean checkPassword(String password_plaintext, String stored_hash) { |
26 |
| - boolean password_verified = false; |
| 22 | + return (hashed_password); |
| 23 | + } |
| 24 | + |
| 25 | + public static boolean checkPassword(String password_plaintext, String stored_hash) { |
| 26 | + boolean password_verified = false; |
27 | 27 |
|
28 |
| - if (null == stored_hash) |
29 |
| - throw new java.lang.IllegalArgumentException("Invalid hash provided for comparison"); |
| 28 | + if (null == stored_hash) |
| 29 | + throw new java.lang.IllegalArgumentException("Invalid hash provided for comparison"); |
30 | 30 |
|
31 |
| - password_verified = BCrypt.checkpw(password_plaintext, stored_hash); |
| 31 | + password_verified = BCrypt.checkpw(password_plaintext, stored_hash); |
32 | 32 |
|
33 |
| - return (password_verified); |
34 |
| - } |
| 33 | + return (password_verified); |
| 34 | + } |
35 | 35 |
|
36 | 36 |
|
37 | 37 | enum GetPUser implements PUserCommand, PersistentEntity.ReplyType<Optional<PUser>> {
|
|
0 commit comments