當試圖用錯誤的用戶名/密碼組合來認證,everyauth總是在每一個module.js拋出一個錯誤:352如何在錯誤重定向與Everyauth/Node.js的
./node_modules/everyauth/lib/modules/everymodule.js:352
throw err;
^
Error: Name or password is incorrect.
at gen_err (./node_modules/nano/error.js:93:43)
at Object.couch (./node_modules/nano/error.js:102:48)
at Request.callback (./node_modules/nano/nano.js:147:26)
at Request.<anonymous> (./node_modules/nano/node_modules/request/main.js:314:21)
at Request.emit (events.js:64:17)
at IncomingMessage.<anonymous> (./node_modules/nano/node_modules/request/main.js:295:19)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1231:22)
at Socket._onReadable (net.js:677:27)
這是我的驗證碼:
.authenticate(function (login, password) {
var promise = this.Promise();
var auth = nano.auth(login, password, function(error, document, headers) {
if (error) {
return promise.fail(error);
} else if (document.userCtx.name === login && document.ok === true) {
console.log(login);
var user = nano.user(login, function(error, document, headers) {
console.log(document);
return promise.fulfill(document);
});
}
});
return promise;
})
在正確的用戶/通行證下正常工作並轉發到'loginSuccessRedirect'。但是隨着拋出的錯誤,Node服務器總是掛起並崩潰,而不是重定向到404或401.
你有沒有解決這個問題?遇到同樣的問題,只要承諾失敗,就會拋出異常並關閉節點 – greenimpala
不,我用promise.fulfill代替。 – Patrick
好的,我必須去那,謝謝 – greenimpala