我是NodeJS的新手,我尝试构建一个登录/注册系统.注册工作正常,但我目前无法登录.
我找到了一个使用passport和nodejs的示例应用程序,因此基于此示例,我构建了注册表单和登录表单. http://blog.robertonodi.me/node-authentication-series-email-and-password/
当我尝试登录时,我得到了一个'Unknown authentication strategy "local" error'
.谁能解释我做错了什么?
(编辑:从答案/评论和文件名中添加了一些更改)
app.use(session({
store: new MongoStore({
url: 'mongodb://' + config.url + ':' + config.port + '/' + config.name
}),
secret: 'secretkey',
key: 'skey.sid',
resave: false,
saveUninitialized: false,
cookie : {
maxAge: 604800000 //7 days in miliseconds
}
}));
app.use(passport.initialize());
app.use(passport.session());
require(path.join(__dirname, 'auth.config'))(passport); //Load passport config
app.use(function(req, res, next) {
req.resources = req.resources || {};
// res.locals.app = config.app;
res.locals.currentUser = req.user;
res.locals._t = function (value) { return value; }; …
Run Code Online (Sandbox Code Playgroud) 我是CefSharp的新手.上周我在C#中使用CefSharp构建了我的第一个小程序.这是一个分屏程序.在一个分区我加载了Tweetdeck.它工作正常,但Tweetdeck不存储cookie.每次我启动程序时,我都必须登录.有没有办法保存cookie?
var browser1 = new CefSharp.WinForms.ChromiumWebBrowser("https://tweetdeck.twitter.com/")
{
Dock = DockStyle.Fill,
};
splitContainer1.Panel1.Controls.Add(browser1);
Run Code Online (Sandbox Code Playgroud) 如何发送错误403并呈现包含"您无权访问此页面"消息的页面?
我现在有这个:
res.send(403,"You do not have rights to visit this page");
Run Code Online (Sandbox Code Playgroud)
但我想渲染一个HTML页面而不是基本文本
res.render('no-rights', {title: 'You have no rights to visit this page', text: 'You are not allowed to visited this page. Maybe you are not logged in?'});
Run Code Online (Sandbox Code Playgroud)
具有403状态.
我尝试使用jetty运行一个非常简单的RESTful apache-camel项目.我已按照http://camel.apache.org/restlet.html的说明进行操作.
我的应用程序将运行,但我无法查看我的项目,因为每个函数都会从jetty中提供Error 503.在Eclipse中,我可以在java.util.zip.Zipexecution中看到一些错误.(发布在下面)但我没有使用该lib,我使用maven来获取所有需要的库.
每次搜索都会告诉我JAR/WAR文件可能已损坏,但由于我正在使用Maven(我之前没有使用过),我不知道在哪里查找文件.
我怎么解决这个问题?
完整错误:
[INFO] jetty-9.2.19.v20160908
java.util.zip.ZipException: invalid END header (bad central directory size)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:103)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:109)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
at org.eclipse.jetty.util.resource.JarFileResource.listEntries(JarFileResource.java:314)
at org.eclipse.jetty.util.resource.JarFileResource.list(JarFileResource.java:275)
at org.eclipse.jetty.util.resource.Resource.getAllResources(Resource.java:682)
at org.eclipse.jetty.webapp.MetaInfConfiguration.scanForTlds(MetaInfConfiguration.java:314)
at org.eclipse.jetty.webapp.MetaInfConfiguration.scanJars(MetaInfConfiguration.java:135)
at org.eclipse.jetty.webapp.MetaInfConfiguration.preConfigure(MetaInfConfiguration.java:86)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:468)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:504)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:366)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) …
Run Code Online (Sandbox Code Playgroud) 我有一个函数可以根据给定的参数为我提供一些订单。但是,参数可以为空,在这种情况下,我想$match
单独留下。
这是我目前拥有的代码:
if(req.query.status && typeof(req.query.status) == 'array'){
var match = {
$in: req.query.status
};
}else if(req.query.status){
var match = req.query.status;
}else{
//when empty find all statuses
var match = null;
}
Order.aggregate(
{
$match: {
'shop.nameSlug' : req.query.nameSlug,
}
},
{
$unwind: "$status"
},
{
$match: {
"status.status" : match
}
},
{
$group: {
_id: "$_id",
status: {
$addToSet: "$status"
},
number: {
$first: "$number"
},
date: {
$first: "$date"
},
comment: {
$first: "$comment"
}
} …
Run Code Online (Sandbox Code Playgroud) 我是mongo和node.js的初学者,在现有的项目中,我们有一个带有geolocs商店的集合.我收到以下错误(我删除了一些字段)
"code" : 16755,
"errmsg" : "Can't extract geo keys: { _id: ObjectId('566990eea9c7a38740a305a3'),
id: 50, guid: \"NL7a09b334-7524-102d-a4ef-00163e5faa0c\", version: 0, owner: 118,
published: 1, loc: [ -9999, -9999 ], logo: \"69db95d0-d58d-40cf-80d3-ac80b8c86af8.png\" }
can't project geometry into spherical CRS: [ -9999, -9999 ]"
Run Code Online (Sandbox Code Playgroud)
当我尝试$set
在商店的一些价值观.我看到值-9999,-9999不正确但是当我尝试用(在Robomongo中)替换其他值时,我得到相同的错误.如何修复此错误,以便我可以编辑值loc
并执行操作$set
?
我为我的 WooCommerce 商店编辑了一些模板。我删除了默认价格,因为我使用插件WooCommerce Extra Product Options来启用价格并控制一些特定选项。
现在,我想将可下载的产品添加到我的商店。作者表示,该插件不支持下载,因为没有足够的 API。
因此,我希望价格返回到我的模板中,但仅限于打开“下载”的产品。如何检查产品是否可以通过模板下载?否则,所有可下载的产品都放置在“下载”类别中,因此检查产品是否属于该类别对我来说也有好处。
你能帮助我吗?
是否可以将CefSharp用作"Chrome"?我知道,它是一种Chrome,但网页并没有将CefSharp视为Chrome.故事:我想用CefSharp嵌入WhatsApp Web,但Whatsapp说:只支持Chrome.有没有可能"伪造"Chrome?
我的控制器和手表中有一些功能可以隐藏和显示我页面上的一些元素.
我最初创建了一个对象:
$scope.selectedItems = [];
Run Code Online (Sandbox Code Playgroud)
通过一些功能,我可以选择取消选择项目:
$scope.selectAllItems = function(items){
for(var i =0; i < items.length; i++){
items[i].selected = true;
$scope.selectedItems.push(items[i]._id);
}
}
$scope.deselectAllItems = function(items){
for(var i=0; i<items.length; i++){
items[i].selected = false;
$scope.selectedItems = [];
}
}
$scope.inverseAllItems = function(items){
$scope.selectedItems = [];
for(var i=0; i<items.length; i++){
items[i].selected = items[i].selected ? false : true;
if(items[i].selected)
$scope.selectedItems.push(items[i]._id);
}
}
$scope.selectItem = function(item){
console.log(item.selected);
if(item.selected){
console.log(item._id);
$scope.selectedItems.push(item._id);
}else{
console.log("hier2");
if($scope.selectedItems.indexOf(item._id))
$scope.selectedItems.splice($scope.selectedItems.indexOf(item._id),1)
}
}
Run Code Online (Sandbox Code Playgroud)
还有一块手表 $scope.selectedItems
$scope.$watch("selectedItems", function handleSelectedItemsChange(newValue, oldValue){
console.log("$scope.selectedItems.length", $scope.selectedItems.length);
if($scope.selectedItems.length …
Run Code Online (Sandbox Code Playgroud) 我想通过电报API在一个<pre>
块或```
(HTML或降价解析模式,我没有偏好)发送消息.
文本是一个带有一些换行符的长字符串.为了便于阅读,我想将其作为代码发送.新行采用\n
格式,因此Telegram API可以处理.
但在代码块中我看不到换行符.我已经使用了其他机器人可以在代码块中向我发送一些行,所以我确定它是可能的.
有人可以帮我这个吗?
这是我目前使用的代码:
$url = "https://api.telegram.org/$telegram_apikey/sendMessage?chat_id=$telegram_chatid&parse_mode=Markdown&text=```" . $message ."```";
$telegramResult = file_get_contents($url
);
Run Code Online (Sandbox Code Playgroud)
消息是这样的:
-------------------------------------------- \n
------------ IMPORT RESULTS ---------------- \n
-------------------------------------------- \n
Product count: 12345 \n
Created: 1234 \n
Total time: 200 \n
-------------------------------------------- \n
Run Code Online (Sandbox Code Playgroud) node.js ×3
c# ×2
cefsharp ×2
javascript ×2
mongodb ×2
php ×2
angularjs ×1
express ×1
geolocation ×1
java ×1
jetty ×1
maven ×1
passport.js ×1
telegram ×1
telegram-bot ×1
whatsapp ×1
woocommerce ×1
wordpress ×1