所以我不知道为什么这不起作用.每当我使用cookie进行maxAge时,它都不允许我登录.它将我重定向到/,因此回调正在工作,但会话数据由于某种原因丢失.任何人都可以帮助我吗?
提前致谢.
/**
* Module dependencies.
*/
var express = require('express');
var routes = require('./routes');
var login = require('./routes/login');
var register = require('./routes/register');
var http = require('http');
var path = require('path');
var MongoClient = require('mongodb');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var app = express();
// all environments
app.set('port', process.env.PORT || 3001);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.cookieParser());
app.use(express.session({
secret: '1234567890QWERT',
cookie: {maxAge: 30}
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
var dbc;
var …Run Code Online (Sandbox Code Playgroud) 我ng-bind='data'通过指令将属性添加到元素中
myApp.directive('myDiv', function() {
return {
restrict: 'E',
link: function($scope, element, attrs) {
element.html('<div ng-bind="data">me</div>');
} }; });
function MyCtrl($scope) {
$('#click').click(function() {
$scope.data = 'change';
}); }
Run Code Online (Sandbox Code Playgroud)
但是ng-bind没有按预期工作.
在摩卡,
describe('this message text', function(){
it('and this message text', function(done){
console.log(this); // {} is empty
});
});
Run Code Online (Sandbox Code Playgroud)
如何'this message text' 'and this message text'从测试内部访问?
我试过this对象,但它是空的.
我正在尝试在我的应用程序中添加带有护照的google身份验证,这是使用yeoman fullstack-generator生成的.
在我的登录控制器内我有这个请求:
$scope.googleAuth = function(){
$http.get('/auth/google');
};
Run Code Online (Sandbox Code Playgroud)
但是,当我调用此函数时,我有这个错误:
XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=h…d=<my-client-ID-here>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
我试图修复在express.js文件中添加中间件层的问题:
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:9000');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Set to true if you need the website to include cookies …Run Code Online (Sandbox Code Playgroud) 我正在尝试将提交推送到heroku,但它没有给出这个错误
Total 93 (delta 62), reused 0 (delta 0)
-----> Node.js app detected
Run Code Online (Sandbox Code Playgroud)
parse error: Invalid numeric literal at line 31, column 7
Run Code Online (Sandbox Code Playgroud)
! Push rejected, failed to compile Node.js app
To git@heroku.com:~.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:~.git'
Run Code Online (Sandbox Code Playgroud)
哪个文件引用了第31行的错误?
该应用程序在本地工作正常.
也许我错过了一些非常微不足道的事情,但我找不到答案。
我正在为客户端实现一个基于 Nodejs、Express 和 Angular 的 Web 应用程序。我通过 Passport.js 处理我的注册和会话。因此,在服务器端,我可以通过request.user. 现在,我有一个登录用户,该用户进入其个人资料页面,通过角度视图显示。
问题是:现在为了向他们显示用户信息,我正在考虑$http向服务器发送请求,该服务器将用户从request显示的客户端发送回客户端。然而,这对我来说听起来很奇怪。
所以这是我的问题:有什么方法可以通过角度访问会话中的用户吗?如果是这样,客户端中实际存储了哪些用户信息?
提前致谢,如果这个问题太微不足道而无法提出,我们深表歉意:/
我正在尝试$watch在我的指令link函数中使用元素的高度.
设置元素的高度,使其(最终)等于窗口高度.所以它应该随着窗口大小调整而改变.
但是,在调整窗口大小时不会更新.
angular.module('app', []).directive('element', function($interval) {
return {
restrict: 'E',
link: function(scope, element) {
scope.$watch(
function() {
return element.height();
},
function(height) {
console.log('element updated', element.height());
});
},
};
});Run Code Online (Sandbox Code Playgroud)
element {
display: block;
border: 1px dotted;
}
* {
height: 100%;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
<element>test</element>
</div>Run Code Online (Sandbox Code Playgroud)
我已经阅读了这个相关的问题,但我不明白为什么他们使用2个指令或者它们如何变得有用.我确实尝试了两个$watches,类似于他们在那里所做的,但它也没有帮助.
angular.module('app', []).directive('element', function($interval) {
return {
restrict: 'E',
link: function(scope, element) {
scope.$watch('__height',
function(height) {
console.log('element updated', element.height()); …Run Code Online (Sandbox Code Playgroud)我有一个带有一些子元素display: flex的<summary>标签<p>.它应该排成一排,对吗?它确实如此,但仅限于Firefox.不在Chrome上(43.0.2357.81).只有我吗?

http://jsfiddle.net/laggingreflex/5e83uqf9/
summary {
display: flex;
flex-flow: row wrap;
}
summary h3 {
display: block;
flex: 1 100%;
}Run Code Online (Sandbox Code Playgroud)
<summary>
<h3>Heading</h3>
<p>1</p>
<p>2</p>
<p>3</p>
</summary>Run Code Online (Sandbox Code Playgroud)
我有一个功能factory:
function factory(events) {
for(const key in events) {
const { before, after } = events[key]
}
}
Run Code Online (Sandbox Code Playgroud)
参数events通常是:
{
only: {
before(){}
after(){}
},
except: {
before(){}
after(){}
},
}
Run Code Online (Sandbox Code Playgroud)
其中键only,except可以是任何内容,但值始终(必须是)类型,{before, after}其中before,after都是函数。
如何使用 JSDoc 记录函数events中参数的结构factory?
我能想到的唯一解决方案是创建events一个数组,然后我可以typedef像这样使用:
/**
* @typedef event
* @property {function} before
* @property {function} after
*/
/**
* @typedef eventTuple
* @property {string} key …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的机车项目中配置passport-twitter.
问题是在点击/ auth/twitter网址后没有任何反应.
编辑:我点击了控制器,但似乎没有调用twitter.
我做的是在routes.js上设置匹配/ auth/twitter并将其映射到auth_controller.js
类似下面的代码:
routes.js
this.match('auth/twitter/', 'auth#twitter');
this.match('auth/twitter/callback/', 'auth#callback');
Run Code Online (Sandbox Code Playgroud)auth_controller.js
var locomotive = require('locomotive')
, Controller = locomotive.Controller
, passport = require('passport');
var AuthController = new Controller();
AuthController.twitter = function() {
console.log('[##] AuthController.twitter [##]');
passport.authenticate('twitter'), function(req, res) {};
}
AuthController.callback = function() {
console.log('[##] AuthController.callback [##]');
passport.authenticate('twitter', { failureRedirect: '/show' }),
function(req, res) {
res.redirect('/list');
};
}
module.exports = AuthController;
Run Code Online (Sandbox Code Playgroud)我真的不知道这是否是用于机车的正确方法,任何帮助都将非常感激.
干杯,法比奥
angularjs ×4
passport.js ×4
node.js ×3
express ×2
cookies ×1
css ×1
flexbox ×1
heroku ×1
html ×1
http ×1
javascript ×1
jsdoc ×1
locomotivejs ×1
mean-stack ×1
mocha.js ×1
ng-bind ×1
session ×1