1
'remoteMethods 모델 내에서 토큰 사용자 아이디를 복구하는 데 문제가 있습니다.헤더의 루프백 토큰을 사용합니다.
User.beforeRemote('**', function(ctx, user, next) {
//...some custom token decoding
ctx.req.body.user_id = token.user_id;
console.log('token : ', token);
next();
});
후, 내 모델 내에서 내가 사용 :
User.check = function (user_id, cb) {
// Do stuff..
};
User.remoteMethod(
'check',
{
http: {path: '/check', verb: 'post'},
returns: {arg: 'rate', type: 'object'},
accepts: [
{
arg: 'user_id',
type: 'number',
required: true,
description: "id of the user to check",
http: function getUserid(ctx) {
console.log('User.check http body : ', ctx.req.body);
return ctx.req.body.user_id;
}
}
],
description: ''
}
);
문제가 내 인수의 기능 'GETUSERID'는 'User.beforeRemote'호출하기 전에 트리거됩니다 있다는 것입니다 나는 다음과 같은 코드를 사용했다.
버그입니까? 내가 어떻게이 일을 할 수 있었는지 알았어? 내가 사용하지 않으려
arg : {http : {source : 'body'}},
난 단지 원격 메소드의 USER_ID의 인수를 갖고 싶어하기 때문에, 나는 약 20 ~ 30 기존의 방법
고맙습니다에서이 작업을 수행해야부터!