【发布时间】:2019-12-19 02:32:55
【问题描述】:
我有这样的User 类:
@Data
@Entity
public class User {
@Id @GeneratedValue Long userID;
String eMail;
String passwordHash;
}
我有这样的数据:
[{"userID":1,"passwordHash":"asdasd","email":"admin@admin.com"},
{"userID":2,"passwordHash":"12345","email":"admin1asdasd@admin.com"}]
我有两种方法,一种是获取单个用户:
// Single item
@GetMapping("/user/{id}")
User one(@PathVariable Long id) {
return repository.findById(id)
.orElseThrow(() -> new UserNotFoundException(id));
}
其他检索所有用户的方法:
// Aggregate root
@GetMapping("/user")
List<User> all() {
return repository.findAll();
}
现在我该如何匹配密码?什么是有效的方法?
【问题讨论】:
-
我将向存储库添加一个新方法,该方法对电子邮件和密码哈希的组合进行选择。
-
匹配哪个密码?你的意思是输入一个未哈希的密码,找出所有用户的密码与输入的密码相同?
标签: json spring-boot jpa passwords