我在弄清楚如何使用 springboot 在 angularjs 中创建登录表单时遇到了一些麻烦。
我可以注册一个用户并将数据发送到数据库,但是当我想登录时问题就开始了。
在 angularjs 我有这样的功能
function Login(username, password, callback) {
$http.post('/api/authenticate', { username: username, password: password })
.success(function (response) {
callback(response);
});
}
我设法做但可能是不对的:
@RequestMapping(value = "/authenticate/{id}",method = RequestMethod.GET)
public User getUser(@PathVariable Integer id) {
return repo.findOne(id);
}
这给了我以下 json
{"id":2,"username":"jdoe","password":"$2a$10$5hgIyQr.K9wb8cXEyWGbROAU.rkYzd19vP7ajHpwp1KUYdShfcPn.","lastname":"doe","firstname":"john","customfield":"Hello there"}
但现在我有以下问题和疑问:
如何通过 api/authenticate 检查用户名和密码是否等于 json 的用户名和密码?(没有 {id})
我可以对用户隐藏这个 json 吗?
这安全吗?
现在所有用户的属性将如何变化?(我建议我可以从 json 中检索它)
关于如何解决这个问题的任何专业提示?