认证后获取 JWT 对象
Getting JWT object after authentication
我使用 feathers generate authentication
创建了一个身份验证,并使用 feathers generate service
创建了一个需要身份验证的服务。
我根本没有对此进行任何代码更改。
所以我有以下内容:
app.service('authentication').hooks({
before: {
create: [
authentication.hooks.authenticate(config.strategies)
],
remove: [
authentication.hooks.authenticate('jwt')
]
}
});
我想知道,在成功验证 JWT 令牌后,我如何才能将该对象放入我的服务构造函数中?
在我的服务中,我有:
module.exports = {
before: {
all: [
authenticate('jwt'),
hook => { console.log(hook.params.payload); }
],
哪个控制台记录有效负载,但我只是不知道如何实际保存它以便我的服务可以访问它。
我发现如果你看 params
它就在那里。
class Service {
constructor (options) {
this.options = options || {};
}
async find (params) {
console.log(params);
..
.
我使用 feathers generate authentication
创建了一个身份验证,并使用 feathers generate service
创建了一个需要身份验证的服务。
我根本没有对此进行任何代码更改。
所以我有以下内容:
app.service('authentication').hooks({
before: {
create: [
authentication.hooks.authenticate(config.strategies)
],
remove: [
authentication.hooks.authenticate('jwt')
]
}
});
我想知道,在成功验证 JWT 令牌后,我如何才能将该对象放入我的服务构造函数中?
在我的服务中,我有:
module.exports = {
before: {
all: [
authenticate('jwt'),
hook => { console.log(hook.params.payload); }
],
哪个控制台记录有效负载,但我只是不知道如何实际保存它以便我的服务可以访问它。
我发现如果你看 params
它就在那里。
class Service {
constructor (options) {
this.options = options || {};
}
async find (params) {
console.log(params);
..
.