我正在开发一个nodejs应用程序并使用passportjs进行身份验证.我正在使用当地的护照策略.但是当我尝试登录时,我收到以下错误:
Error: Unknown authentication strategy "local"
at attempt (/home/project/node_modules/passport/lib/middleware/authenticate.js:166:37)
at authenticate (/home/project/node_modules/passport/lib/middleware/authenticate.js:338:7)
at exports.authenticate (/home/project/controllers/RegistrationsController.js:87:4)
at callbacks (/home/project/node_modules/express/lib/router/index.js:164:37)
at param (/home/project/node_modules/express/lib/router/index.js:138:11)
at pass (/home/project/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/home/project/node_modules/express/lib/router/index.js:173:5)
at Object.router (/home/project/node_modules/express/lib/router/index.js:33:10)
at next (/home/project/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at /home/project/node_modules/express-flash/lib/express-flash.js:31:7
Run Code Online (Sandbox Code Playgroud)
这是我的passport-config.js文件:
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var User = require('../models/user');
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
User.findById(id, function (err, user) {
done(err, user);
});
});
passport.use({usernameField: 'emailAddress'}, new LocalStrategy(function(username, password, done) {
User.findOne({ emailAddress: username }, function(err, user) { …Run Code Online (Sandbox Code Playgroud) 我正在使用mongoose ODM开发一个使用mongodb的节点应用程序.我在类型引用驻留在不同文件中的模式时收到错误.
我在user.js文件中有以下代码:
var mongoose = require('mongoose');
var Trip = require('./trip');
var userSchema = mongoose.Schema({
firstName: String,
lastName: String,
salt: String,
hash: String,
emailAddress: {
type: String,
unique: true
},
trips: [{Type: mongoose.Schema.Types.ObjectId, ref: 'Trip'}]
});
module.exports = mongoose.model('User', userSchema);
Run Code Online (Sandbox Code Playgroud)
userSchema具有对tripSchema的类型引用.
我的trip.js文件中的代码是:
var tripSchema = mongoose.Schema({
name: String,
location: String,
arrivalDate: Date,
departureDate: Date,
type: String});
module.exports = mongoose.model('Trip', tripSchema);
Run Code Online (Sandbox Code Playgroud)
当我运行该应用程序时,我收到以下错误:
/usr/lib/node_modules/mongoose/lib/schema.js:360
throw new TypeError('Undefined type at `' + path +
^
TypeError: Undefined type at `trip.ref`
Did you try …Run Code Online (Sandbox Code Playgroud) 我们使用nginx服务器来反向代理很少的微服务.每个请求都Authorization包含包含JWT令牌的标头.现在,我们需要做的是从JWT令牌中提取用户详细信息并将其记录在nginx服务器上.无论如何解码和登录JWT?我查看了几个用于使用JWT验证请求的lua脚本,但这不是我们需要的.此外,我们试图避免在nginx服务器上安装Lua.
任何帮助将不胜感激.
编辑:我们也很适合基于Lua的解决方案.
我想在我的Android应用程序中集成Google Plus登录.当我尝试在Android Google API模拟器上运行此应用程序时,会出现一个对话框,提示我更新"Google Play服务".单击"更新"按钮没有任何反应,我可以在logcat中看到以下错误:
Can't redirect to app settings for Google Play services
Run Code Online (Sandbox Code Playgroud)
我也在logcat中收到以下警告:
Google Play services out of date. Requires 3225100 but found 3158130
Run Code Online (Sandbox Code Playgroud)
另外我想补充一点,我已将Google Play服务从版本8更新到版本10.
有人可以告诉我如何在模拟器上更新Google Play服务吗?
我知道Stack Overflow上有很多关于这个主题的问题,但似乎没有什么对我有用.任何帮助将不胜感激.
我对GraphQL有问题。我想将axios.post请求发送到我的服务器。我可以用邮递员来做:
{
"query":"mutation{updateUserCity(userID: 2, city:\"test\"){id name age city knowledge{language frameworks}}} "
}
Run Code Online (Sandbox Code Playgroud)
在graphiql中:
mutation {
updateUserCity(userID: 2, city: "test") {
id
name
age
city
knowledge {
language
frameworks
}
}
}
Run Code Online (Sandbox Code Playgroud)
但无法在我的代码中执行:(((这是我的代码段:
const data = await axios.post(API_URL, {
query: mutation updateUserCity(${ id }: Int!, ${ city }: String!) {
updateUserCity(userID: ${ id }, city: ${ city }){
id
name
age
city
knowledge{
language
frameworks
}
}
}
}, {
headers: {
'Content-Type': 'application/json'
}
})
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题?