0
林上node.js的運行Web認證系統的工作,表達和everyauth。代碼的每一部分都從here複製粘貼,雖然我沒有密碼身份驗證運行 - 我得到了螞蟻異常,同時嘗試POST表格數據。 Excepction在節點控制檯:的Node.js,Epxress和everyAuth - 「無法讀取的<...>財產」
TypeError: Cannot read property 'login' of undefined
at Object.module.exports.everyModule.submodule.configurable.loginFormFieldName.passwordFormFieldName.loginHumanName.loginKey.get.step.accepts.promises.displayLogin.post.step.accepts.promises.step.accepts.promises.step.description.accepts.promises.step.description.accepts.promises.step.description.accepts.promises.step.description.accepts.promises.step.description.accepts.promises.extractLoginPassword.interpretUserOrErrors.getSession.addToSession.sess.auth.sess.auth [as _extractLoginPassword] (D:\xampp\htdocs\KO_\node_modules\everyauth\lib\modules\password.js:188:21)
at Object.Step.exec (D:\xampp\htdocs\KO_\node_modules\everyauth\lib\step.js:47:21)
at RouteTriggeredSequence.StepSequence.start (D:\xampp\htdocs\KO_\node_modules\everyauth\lib\stepSequence.js:46:39)
at RouteTriggeredSequence.routeHandler (D:\xampp\htdocs\KO_\node_modules\everyauth\lib\routeTriggeredSequence.js:13:13)
at nextMiddleware (D:\xampp\htdocs\KO_\node_modules\everyauth\node_modules\connect\lib\middleware\router.js:175:25)
at param (D:\xampp\htdocs\KO_\node_modules\everyauth\node_modules\connect\lib\middleware\router.js:183:17)
at pass (D:\xampp\htdocs\KO_\node_modules\everyauth\node_modules\connect\lib\middleware\router.js:191:11)
at Object.router (D:\xampp\htdocs\KO_\node_modules\everyauth\node_modules\connect\lib\middleware\router.js:197:7)
at next (D:\xampp\htdocs\KO_\node_modules\everyauth\node_modules\connect\lib\http.js:204:15)
at Object.fetchUserFromSession [as handle] (D:\xampp\htdocs\KO_\node_modules\everyauth\index.js:33:43)
我的代碼片段:
everyauth.password
.loginWith('login')
.getLoginPath('/login')
.postLoginPath('/login')
.loginView('loginForm.jade')
.authenticate(function (login, password) {
console.log("login + password");
var errors = [];
if (!login) errors.push('Missing login');
if (!password) errors.push('Missing password');
if (errors.length) return errors;
var user = usersByLogin[login];
if (!user) return ['Login failed'];
if (user.password !== password) return ['Login failed'];
return user;
})
.getRegisterPath('/register')
.postRegisterPath('/register')
.registerView('register.jade')
.validateRegistration(function (newUserAttrs, errors) {
var login = newUserAttrs.login;
if (usersByLogin[login]) errors.push('Login already taken');
return errors;
})
.registerUser(function (newUserAttrs) {
var login = newUserAttrs[this.loginKey()];
return usersByLogin[login] = addUser(newUserAttrs);
})
.loginSuccessRedirect('/')
.registerSuccessRedirect('/');
任何想法?