bnoguchi / mongoose-auth

User authentication plugin for mongoose nodejs orm
https://github.com/bnoguchi/mongoose-auth
740 stars 113 forks source link

TypeError: Cannot read property 'email' of undefined #94

Closed davisford closed 12 years ago

davisford commented 12 years ago

Hi, I'm trying mongoose-auth with socketstream + jade.

I have twitter/google oauth working, but I'm trying to get password forms to work. Any tips on how to resolve the undefined 'email' property? My server.js is nearly identical to example/server.js

login.jade =>

form.well.form-inline(action="/login", method="post")
  input.input-small#login(type="text", placeholder="email", name=everyauth.password.loginFormFieldName)
  input.input-small#password(type="password", placeholder="password", name=everyauth.password.passwordFormFieldName)
  label.checkbox Remember me
    input#submit(type="checkbox") 
  button.btn(type="submit") Sign in
  div.btn-group
    a.btn(href="/auth/twitter") Login with Twitter
    a.btn(href="/auth/facebook") Login with Facebook
    a.btn(href="/auth/google") Login with Google 

If I submit, it generates this:

TypeError: Cannot read property 'email' of undefined
    at Object._extractLoginPassword (/home/davis/git/daisycentral/node_modules/everyauth/lib/modules/password.js:188:21)
    at Object.exec (/home/davis/git/daisycentral/node_modules/everyauth/lib/step.js:47:21)
    at RouteTriggeredSequence.start (/home/davis/git/daisycentral/node_modules/everyauth/lib/stepSequence.js:46:39)
    at RouteTriggeredSequence.routeHandler (/home/davis/git/daisycentral/node_modules/everyauth/lib/routeTriggeredSequence.js:13:13)
    at Object.<anonymous> (native)
    at nextMiddleware (/home/davis/git/daisycentral/node_modules/everyauth/node_modules/connect/lib/middleware/router.js:175:25)
    at param (/home/davis/git/daisycentral/node_modules/everyauth/node_modules/connect/lib/middleware/router.js:183:16)
    at pass (/home/davis/git/daisycentral/node_modules/everyauth/node_modules/connect/lib/middleware/router.js:191:10)
    at Object.router [as handle] (/home/davis/git/daisycentral/node_modules/everyauth/node_modules/connect/lib/middleware/router.js:197:6)
    at next (/home/davis/git/daisycentral/node_modules/everyauth/node_modules/connect/lib/http.js:203:15)

Here's what the login input looks like in the DOM:

<input id="login" type="text" placeholder="email" name="function (setTo) {
        var k = '_' + property;
        if (arguments.length) {
          this[k] = setTo;
          return this;
        }
        // TODO this.everyauth is not yet available here in some contexts
        //      For example, when we set and try to access a scope in an auth module definition
        //      but if you look in index, everyauth is not assigned to the module until after it is
        //      required
        if (this.everyauth &amp;&amp; this.everyauth.debug &amp;&amp; 'undefined' === typeof this[k]) {
          var debugMsg = 'WARNING: You are trying to access the attribute/method configured by `' +
                         property + '`, which you did not configure. Time to configure it.';
          console.log(debugMsg);
          console.trace();
        }
        return this[k];
      }" class="input-small">
davisford commented 12 years ago

socketstream express helper vars are not available to jade -- that's just the way it is.