我正在使用Express、Mongoose、Passport和JWT实现授权功能。
我可以注册一个用户。我能够进行身份验证并生成一个JWT,我可以在JWT站点上解析它,但是由于某些原因,我得到了一个未知的身份验证策略错误消息。
我把我的所有代码块放在一个Plunker实例上,地址是:
下面是我的passport.js文件,其中包含我的策略:
var JwtStrategy = require('passport-jwt').Strategy;
// load up the user model
var User = require('../models/user
我找到了用NuxtJS - VueJS进行身份验证的全局配置Axios的方法(我主要使用NUXTJS)。
我所需要的是:如果用户登录并在$store中拥有令牌,axios将得到这个令牌。如果用户是匿名的,则axios将不会获得此令牌。
~/plugins/axios
import axios from 'axios'
import AuthenticationStore from '~/store'
var api = axios.create({
baseURL: 'http://localhost:8000/api/v1/',
我一直在
res.jwt is not a function
我安装了jwt-express并像这样导入了它
import jwt from 'jwt-express'
这是我的auth.js
import Account from '../services/account.js'
import env from 'dotenv'
import _ from 'lodash'
const dotenv = env.config();
module.exports = {
/**
* Process th
我在我的网站上显示了一些从节点服务器返回的数据。一直工作到今天。现在,当我转到我的网页时,我在我的服务器控制台上得到了下面的错误。我在用户中使用Auth0作为登录。
UnauthorizedError: invalid algorithm
at C:\workspace\New\MyApp\node_modules\express-jwt\lib\index.js:100:22
at C:\workspace\New\MyApp\node_modules\express-jwt\node_modules\jsonwebtoken\index.js:155:18
at n