我在数据库中有两个用户,他们有相同的电子邮件和密码,但角色不同。它看起来像:
email pass roles
+------------+------+-------
1@gmail.com 123 user
1@gmail.com 123 admin
当用户尝试登录时,我发送带有参数的请求
{
email:"1@1.ru"
password:"123"
roles:"user"
strategy:"local"
}
问题是:我如何通过角色识别用户(当我使用参数角色从前端请求发送时:“用户”用户必须通过角色“用户”登录,当角色:“管理员” - 由管理员)
这是我的来自 auth 的钩子
app.service('authentication').hooks({
before: {
create: [
authentication.hooks.authenticate(['local', 'jwt'])
],
remove: [
authentication.hooks.authenticate('jwt')
]
},