首页 \ 问答 \ 没有从JWT的有效载荷中获得所有的字段(not getting all the fields from payload of JWT)

没有从JWT的有效载荷中获得所有的字段(not getting all the fields from payload of JWT)

我创建了一个MEAN堆栈web应用程序,它具有登录注销选项。用户登录后,我使用了jsonwebtoken npm软件包。 这里的主要问题是当用户登录一个JWT时被创建,并且该令牌的有效负载包含用户名,电子邮件和全名,但是在解码令牌时我只获取用户名和电子邮件字段

这里是jwt.sign函数 -

var token=jwt.sign({userid:user.username,email:user.email,fullname:user.fullname},secret,{expiresIn:'24h'});

这里jwt.verify方法 -

jwt.verify(token,secret,function(err,decoded){
    if(err){
        res.json({success:false,message:"invalid token"});
    } else {
        req.decoded=decoded;
        next();
    }
})

令牌示例 -

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJuaXRpbi5zYWNoZGV2IiwiZW1haWwiOiJuaXRpbi5zYWNoZGV2QGVtYWlsLmNvbSIsImlhdCI6MTQ4NDU1ODAxMiwiZXhwIjoxNDg0NjQ0NDEyfQ.fWogT-aHJY4Xyc8Ebm4OXPkWD3poaWG3IAAf9VS-q58

令牌解码 -

{
    "userid": "nitin.sachdev",
    "email": "nitin.sachdev@email.com",
    "iat": 1484558012,
    "exp": 1484644412
}

userSchema -

 var UserSchema=new Schema({
    fullname:String,
    username:{type:String,lowercase:true,required:true,unique:true},
    password:{type:String,required:true},
    email:{type:String,required:true,lowercase:true,unique:true},
    contactno:Number,
    orgname:String
});

i have created a MEAN stack web app which has login logout option.for user to be logged in i have used jsonwebtoken npm package. the main problem here is when user logs in a JWT is created and in that token's payload contain username,email and fullname but while decoding the token i am only getting username and email field

here is jwt.sign function-

var token=jwt.sign({userid:user.username,email:user.email,fullname:user.fullname},secret,{expiresIn:'24h'});

and here jwt.verify method-

jwt.verify(token,secret,function(err,decoded){
    if(err){
        res.json({success:false,message:"invalid token"});
    } else {
        req.decoded=decoded;
        next();
    }
})

token example-

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJuaXRpbi5zYWNoZGV2IiwiZW1haWwiOiJuaXRpbi5zYWNoZGV2QGVtYWlsLmNvbSIsImlhdCI6MTQ4NDU1ODAxMiwiZXhwIjoxNDg0NjQ0NDEyfQ.fWogT-aHJY4Xyc8Ebm4OXPkWD3poaWG3IAAf9VS-q58

token decoded-

{
    "userid": "nitin.sachdev",
    "email": "nitin.sachdev@email.com",
    "iat": 1484558012,
    "exp": 1484644412
}

userSchema -

 var UserSchema=new Schema({
    fullname:String,
    username:{type:String,lowercase:true,required:true,unique:true},
    password:{type:String,required:true},
    email:{type:String,required:true,lowercase:true,unique:true},
    contactno:Number,
    orgname:String
});

原文:https://stackoverflow.com/questions/41673114
更新时间:2023-04-19 09:04

最满意答案

--emscripten_dir和Empscripten路径之间不应该有= 。 输出文件夹也应该是最后一个参数。 像这样尝试:

python ./platforms/js/build_js.py --emscripten_dir /root/Downloads/emsdk-portable/emscripten/1.37.33 /root/Downloads/opencvjspackage

提示:确保/root/Downloads/opencvjspackage存在,并且是要将opencv.js内置到的位置。 还要确保cmake已安装。


There should be no = between --emscripten_dir and the Empscripten path. Also the output folder should be the last argument. Try like this:

python ./platforms/js/build_js.py --emscripten_dir /root/Downloads/emsdk-portable/emscripten/1.37.33 /root/Downloads/opencvjspackage

Tip: make sure /root/Downloads/opencvjspackage exists and is where you want opencv.js to be built into. Also make sure cmake is installed.

相关问答

更多
  • Windows上的PATH环境变量不需要引号。 set PATH=C:\Program Files (x86)\CMake\bin\;%PATH% Quotes aren't needed in PATH environmental variables on Windows. set PATH=C:\Program Files (x86)\CMake\bin\;%PATH%
  • 使用BUILD_AS_WORKER标志进行编译。 emcc -std=c++11 worker.cpp -s EXPORTED_FUNCTIONS="['_one']" -s BUILD_AS_WORKER=1 -o worker.js Compile with BUILD_AS_WORKER flag. emcc -std=c++11 worker.cpp -s EXPORTED_FUNCTIONS="['_one']" -s BUILD_AS_WORKER=1 -o worker.js
  • emcc文档中有两个可以帮助的命令行选项, - --pre-js 和--pre-js --post-js 。 它们允许您包装生成的代码,因此允许您与AMD集成。 例如,您可以使用前缀文件 // prefix.js define(function() { return function(Module) { 和后缀文件 // postfix.js }; }); 您将使用类似的东西编译输出到myModule.js emcc --pre-js prefix.js ...
  • 我对此感到沮丧,最终建立了一个完美编译的Ubuntu系统。 I got frustrated with this and ended up building a Ubuntu system which compiles things perfectly.
  • 在--emscripten_dir和Empscripten路径之间不应该有= 。 输出文件夹也应该是最后一个参数。 像这样尝试: python ./platforms/js/build_js.py --emscripten_dir /root/Downloads/emsdk-portable/emscripten/1.37.33 /root/Downloads/opencvjspackage 提示:确保/root/Downloads/opencvjspackage存在,并且是要将opencv.js内置到的 ...
  • 这似乎是1.34.1中的回归。 我有完全相同的问题。 升级到1.34.6后,错误消失了。 我没有修改它,但我建议你也更新到1.34.6+。 This appear to be a regression in 1.34.1. I had the exact same issue. After upgrading to 1.34.6 the error went away. I don't which commit fixed it but I would suggest you also update to ...
  • 我建议你使用Cheerp - emscripten的替代品 - Cheerp有一个可用的WebGL演示,它也有更多连贯/更新的文档/示例 I suggest you use Cheerp - an alternative to emscripten - Cheerp has a working WebGL demo, it also has much more coherent/updated docs/examples
  • 这看起来非常类似于此处报告的问题: https : //github.com/kripken/emscripten/issues/1432 This looks very similar to the issue reported here: https://github.com/kripken/emscripten/issues/1432
  • 在cmake调用中指定编译器是不够的,您需要工具链。 为此,请使用emcmake cmake [options] 。 它将使用emscripten设置编译所需的一切。 Specifying the compiler in the cmake call is not enough, you need the toolchain. To do that, use emcmake cmake [options]. It will set everything you need to compile using e ...
  • preamble.js本身不能在浏览器中加载,但是当你使用emscripten生成一个JavaScript(或HTML)输出文件时(例如通过调用emcc foo.c -o foo.js ),它将包含一个预处理版本前导码以及输出文件中的asm.js代码。 (或者,如果您使用WebAssembly,它还将生成foo.wasm文件以与foo.js一起使用)。 输出foo.js文件应该可以在浏览器中加载(或者例如node.js,如果它不使用Web API)。 preamble.js by itself can't ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)