我正在操纵(这可能是一个动词吗?)一个使用 webpack 构建的应用程序,page.on('error')我收到如下错误:
TypeError: __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise___default.a.map is not a function
at _default.<anonymous> (....../app.js:23858:89)
at Generator.next (<anonymous>)
at step (....../app.js:35041:30)
at ....../app.js:35052:13
Run Code Online (Sandbox Code Playgroud)
有没有办法,如果有的话我怎样才能正确地对这些错误进行源映射?
(我确信我正在生成源映射)
身份验证模块"Passport"需要FindOrCreate方法才能进行登录.我使用mongoose以使用以下架构保存我的用户:
var UserSchema = new Schema({
firstname: String,
lastname: String,
email: String,
accounts: []
});
Run Code Online (Sandbox Code Playgroud)
accounts数组包含代表facebook帐户的对象,例如{provider: "facebook", uid: "someFacebookId"}.
我的身份验证策略如下所示:
// Authentication Strategy
passport.use(new FacebookStrategy({
clientID: CONFIG.fb.appId,
clientSecret: CONFIG.fb.appSecret,
callbackURL: CONFIG.fb.callbackURL
},
function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
User.find({ 'accounts.uid': profile.id, 'accounts.provider': 'facebook' }, function(err, olduser) {
if(olduser._id) {
console.log('User: ' + olduser.firstname + ' ' + olduser.lastname + ' found and logged in!');
done(null, olduser);
} else {
var newuser …Run Code Online (Sandbox Code Playgroud) 我有两个主机名由我的DNS发送到同一个IP:
我在我的Twitter应用程序中明确设置了我的回调和域名theark.info.确保我可以使用相同的Twitter App for Oauth的最佳方法是什么www.theark.info,因为我目前收到错误:
内部服务器错误
在我的DNS CNAME www中,我的DNS指向了theark.info
也许我需要使用Express和Javacsript对请求操纵DOM?
我在node.js应用程序中使用passport.js来使OAuth工作(太棒了!),但是现在,我遇到了一件事有问题.
我在客户端使用backbone.js来创建视图(我正在尝试创建一个SinglePage应用程序......),而我正在考虑在骨干网中获取用户ID或类似内容的唯一方法是创建首先输入隐藏在jade模板中,然后将其传递给我的主干视图中的构造函数....或者只是将值赋给javascript变量并将其传递给管理所有视图的路由器,并将其传递给每个视图需要它
我认为这不是一个好主意,可能有更好的选择!
你会怎么做?
谢谢!
我使用Passport-Linkedin策略为Passport with Express,允许用户使用他们的LinkedIn个人资料登录.
我有以下代码:
passport.use(new LinkedInStrategy({
consumerKey: config.linkedin.LINKEDIN_API_KEY,
consumerSecret: config.linkedin.LINKEDIN_SECRET_KEY,
callbackURL: "http://localhost:3000/auth/linkedin/callback"
},
function(token, tokenSecret, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
// To keep the example simple, the user's LinkedIn profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the LinkedIn account with a user record in your database,
// and return that user instead.
return done(null, profile);
});
}
));
Run Code Online (Sandbox Code Playgroud)
在第4行,我必须手动设置完整的回调URL.我有一个用于生产的字符串和一个用于开发的字符串,但我的URL不断变化,端口也是如此(我使用2台机器进行开发).
如何http://localhost:3000自动设置URL()的第一部分?有没有的属性 …
我想通过生成随机用户名和密码自动生成用户帐户,然后用户自动登录(用户不知道他的用户名/密码,他的浏览器只存储会话cookie).
Passport作为中间件,所以如何验证我刚刚生成的用户?或者,以某种方式重定向到我的app.post('/login')路线并发送这些变量会更好吗?(但不知何故将这些发送到浏览器,只是被发送回服务器似乎不是非常安全或有效).
app.get('/signup', function(req, res) {
if(req.isAuthenticated()) { res.redirect('/'); }
else {
var today = new Date();
var weekDate = new Date();
weekDate.setDate(today.getDate() + 7);
var key1 = Math.random().toString();
var key2 = Math.random().toString();
var hash1 = crypto.createHmac('sha1', key1).update(today.valueOf().toString()).digest('hex');
var hash2 = crypto.createHmac('sha1', key2).update(weekDate.valueOf().toString()).digest('hex');
var newUser = new models.User({
username: hash1,
password: hash2,
signupDate: today,
accountStatus: 0,
expirationDate: weekDate,
});
newUser.save(function(err) {
if(err) {}
console.log("New user created.");
//HOW CAN I PASS USERNAME AND PASSWORD ARGUMENTS???
passport.authenticate('local')();
res.redirect('/login');
})
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用redis with express来创建用户登录和会话.我使用这个curl脚本测试路由:
curl -d 'email=testEmail&password=testPass' http://localhost:3000/users/session
Run Code Online (Sandbox Code Playgroud)
当我这样做,护照通过序列化工作正常,然后它返回http 302.我没有弄清楚序列化后它做了什么,但当我在浏览器中使用我的登录html表单而不是curl尝试它时,它显示我"未经授权"401,我没有看到任何控制台日志.这是我的app.js:
var express = require('express')
, fs = require('fs')
, cons = require('consolidate')
, http = require('http')
, flash = require('connect-flash')
, passport = require('passport')
, RedisStore = require( "connect-redis" )(express) //for sessions (instead of MemoryStore)
, redis = require('redis')
, env = process.env.NODE_ENV || 'development'
, config = require('./config/config')[env]
, db = redis.createClient(config.db.port, config.db.host);
db.select(config.db.users)
db.auth(config.db.auth);
var app = express();
//require passport strategies (see code block below)
require('./config/passport')(passport, config, app)
app.use('/assets', …Run Code Online (Sandbox Code Playgroud) 我正在使用带有MYSQL(带有sequelize)的LocalStrategy,除非MYSQL抛出异常(只是为了测试,我关闭了MYSQL服务器).该return done(error)回调引发异常崩溃的服务器.
这是我的一段代码:
passport.use(new LocalStrategy({usernameField: 'email', passwordField: 'password'},
function (email, password, done) {
db.User.find({where: {email: email}}).done(function (error, user) {
if(error) return done(error);
if (!user) return done(null, false, {message: 'unknown user'});
//validate password
if (user.password != password) {
return done(null, false, {message: 'invalid password'});
}
//all ok
return done(null, user);
});
}
));
Run Code Online (Sandbox Code Playgroud)
例外情况:
TypeError: Property 'next' of object #<Context> is not a function
at Context.actions.error
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?谢谢!
编辑:
req._passport.instance.authenticate('local', function (err, user, info) {
if (err) return validator.emit('exception', err); …Run Code Online (Sandbox Code Playgroud) 我使用NodeJS,ExpressJS,PassportJS和Jade.
我有一个标题菜单,将显示登录或注销.如果用户尚未登录则显示登录,如果用户已登录则显示登录.
菜单位于单独的玉文件中:menu.jade并包含在其余的玉文件中.
include menu
Run Code Online (Sandbox Code Playgroud)
在menu.jade中,如何检查用户是否已登录?我可以在玉器中检查会话变量吗?像下面的东西menu.jade?
if ( req.session.name != null)
a(href='/logout') Logout
else
a(href='/login') Login
Run Code Online (Sandbox Code Playgroud)
谢谢
node.js ×9
passport.js ×8
express ×6
javascript ×2
pug ×2
backbone.js ×1
css ×1
html ×1
mongoose ×1
puppeteer ×1
redis ×1
source-maps ×1
text ×1
twitter ×1
typography ×1