deitch / activator

Easy user activation and password reset, with email confirmation, for nodejs
85 stars 42 forks source link

model.save(id,{activation_code:code},cb); #2

Closed lemannrus closed 11 years ago

lemannrus commented 11 years ago

Hi. I try to use this module, but i getting this error:

/var/www/web/insights-platform/node_modules/activator/lib/activator.js:112
                        model.save(id,{activation_code:code},cb);
                              ^
TypeError: Object [object Object] has no method 'save'
    at async.waterfall.mailer.code (/var/www/web/insights-platform/node_modules/activator/lib/activator.js:112:13)
    at fn (/var/www/web/insights-platform/node_modules/activator/node_modules/async/lib/async.js:579:34)
    at Object._onImmediate (/var/www/web/insights-platform/node_modules/activator/node_modules/async/lib/async.js:495:34)
    at processImmediate [as _immediateCallback] (timers.js:330:15)

I am using Sails.js. How i can fix that?

deitch commented 11 years ago

Hi @lemannrus

Can you post your code you used to initialize activator? activator.init() with the details? That type of error is usually because the config option user wasn't set. See https://github.com/deitch/activator/blob/master/README.md#initialization

lemannrus commented 11 years ago

Thank you for answer. This is my initialize code:

var activator = require("activator");
        MAILPORT = 25,
            url = "smtp://insights-platform.dev:" + MAILPORT + "/insights-platform.dev/" + escape("Test lemannrus@gmail.com");
        var mailTemplatesDir = __dirname + "/../../assets/mail_templates/";
        var config = {user: User, url: url, templates: mailTemplatesDir};
        activator.init(config);

This is my User model:

module.exports = {
    attributes: {
        username: {
            type: 'string',
            required: true
        },
        password: {
            type: 'string',
            required: true
        },
        firstname: 'string',
        lastname: 'string',
        gravatar: 'boolean',
        userpic: 'string'
    }
}
deitch commented 11 years ago

Ah, there's the issue. You are using the template for a User model, which is just the JS object defining the fields, rather than something that can do .save() and .find().

This is an issue of definitions. In sails, you define the attributes of the model, but the instance itself (what I would call a model) is an object with methods created by sails. Different philosophy, different words, but gets the same thing done.

In other words, in sails, you have a user object that was loaded and has save() built into it; activator expects just a method to which you can pass an id and the attributes and have it save them.

Easiest might be to just make a lightweight bridge:

db = {
  find: function(login,callback) {
    User.findOne({email:login},callback);
  },
  save: function(id,data,callback) {
    User.update({id:id},data,callback);
  }
}

This is interesting. It might be worth making a sails bridge as built right into activator. I come from the booster side, so a little different.

lemannrus commented 11 years ago

Thank you, @deitch. I will try to do this.

deitch commented 11 years ago

I will close out the issue, but can you please post here what works? I like the idea of a sails adapter built right in.

lemannrus commented 11 years ago

Yes, it's work) Save and Find working correctly. But now i getting another error

/var/www/web/insights-platform/node_modules/nodemailer/node_modules/simplesmtp/lib/pool.js:296
        message.returnCallback(error);
                ^
TypeError: Property 'returnCallback' of object #MailComposer is not a function
    at SMTPConnectionPool._onConnectionError (/var/www/web/insights-platform/node_modules/nodemailer/node_modules/simplesmtp/lib/pool.js:296:17)
    at SMTPClient.EventEmitter.emit (events.js:95:17)
    at SMTPClient._onError (/var/www/web/insights-platform/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:319:10)
    at SMTPClient._actionMAIL (/var/www/web/insights-platform/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:852:14)
    at SMTPClient._onData (/var/www/web/insights-platform/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:301:29)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket. (_stream_readable.js:738:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
deitch commented 11 years ago

Hmm... can you put up a gist or set up a github repo I can clone that reproduces it?

lemannrus commented 11 years ago

https://gist.github.com/lemannrus/6433499 - this is my AuthController. Maybe, i doing something wrong?

deitch commented 11 years ago

As an aside, you should look at the excellent async module http://github.com/caolan/async by @caolan, the async.waterfall or async.series would make your registerpost much easier.

lemannrus commented 11 years ago

Ok, but how this module help me to fix this(https://github.com/deitch/activator/issues/2#issuecomment-23710404) problem?

deitch commented 11 years ago

A number of things jump out:

1) (I don't know if this is part of the problem here), you should call activator.init() just once 2) You should pass next to the middleware when calling createActivate or completeActivate 3) createActivate and completeActivate are express-compliant middleware, so when they complete, they expect to call next, unless they fail.

I think the last is a part of the problem, you are calling res.send() and next() in parallel, guaranteed to create problems.

// at the beginning
var config = {user: model, url: url, templates: mailTemplatesDir};
activator.init(config);
// lots of other stuff
module.exports = {
                            // inside registerpost   
                            req.activator = {id: user.id, body: user.id};
                            // make sure to pass it next
                            activator.createActivate(req, res, next);
                            res.redirect('/confirm');

    // further down
    activate: function (req, res, next) {
        activator.completeActivate(req, res, next);
        res.redirect('/activated');
    },

};
deitch commented 11 years ago

Shoot, I forgot, sails doesn't do next!

deitch commented 11 years ago

OK, so short-term, I would do this.

activator.createActivate(req,res,function(){
    res.redirect('/confirm');
});

and

activator.completeActivate(req,res,function(){
    res.redirect('/activated');
});

Long-term, async makes this much easier. I am thinking about modifying activator so it can handle only 2 args, and thus just return a promise.

lemannrus commented 11 years ago

Don't work :( I rewrote the code. I call init() once, and modify create/completeActivate. But still getting the error

deitch commented 11 years ago

Can you modify the gist?

lemannrus commented 11 years ago

Done. I'm sorry, I just started to learn node.js so sometimes make stupid mistakes)

deitch commented 11 years ago

It's the only way to learn anything...

deitch commented 11 years ago

Based on what I am seeing, it looks like there is an error in sending the email; the problem is why it is not handling it well...

lemannrus commented 11 years ago

Maybe the problem is the mail server settings?

deitch commented 11 years ago

Yes and no. The mail server is returning an error. But the error should be better handled by the client-side stack, hold on...

deitch commented 11 years ago

Can you post the output of npm ls ?

lemannrus commented 11 years ago
├─┬ activator@0.2.3
│ ├── async@0.2.9
│ └── lodash@1.3.1
├─┬ bcrypt@0.7.6
│ └── bindings@1.0.0
├── connect-flash@0.1.1
├── ejs@0.8.4
├── elasticsearch@0.3.8
├── gravatar@1.0.6 extraneous
├─┬ grunt@0.4.1
│ ├── async@0.1.22
│ ├── coffee-script@1.3.3
│ ├── colors@0.6.1
│ ├── dateformat@1.0.2-1.2.3
│ ├── eventemitter2@0.4.13
│ ├─┬ findup-sync@0.1.2
│ │ └── lodash@1.0.1
│ ├─┬ glob@3.1.21
│ │ ├── graceful-fs@1.2.3
│ │ └── inherits@1.0.0
│ ├── hooker@0.2.3
│ ├── iconv-lite@0.2.11
│ ├─┬ js-yaml@2.0.5
│ │ ├─┬ argparse@0.1.15
│ │ │ ├── underscore@1.4.4
│ │ │ └── underscore.string@2.3.3
│ │ └── esprima@1.0.3
│ ├── lodash@0.9.2
│ ├─┬ minimatch@0.2.12
│ │ ├── lru-cache@2.3.0
│ │ └── sigmund@1.0.0
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.4
│ ├─┬ rimraf@2.0.3
│ │ └── graceful-fs@1.1.14
│ ├── underscore.string@2.2.1
│ └── which@1.0.5
├─┬ mailer@0.6.7 extraneous
│ ├── colors@0.6.1
│ └─┬ nodemailer@0.1.20
│   └── mimelib-noiconv@0.1.9
├─┬ nodemailer@0.5.2
│ ├─┬ mailcomposer@0.2.1
│ │ ├── mime@1.2.9
│ │ └─┬ mimelib@0.2.12
│ │   ├── addressparser@0.1.3
│ │   └─┬ encoding@0.1.6
│ │     └── iconv-lite@0.2.7
│ └─┬ simplesmtp@0.3.7
│   ├── rai@0.1.7
│   └── xoauth2@0.1.8
├─┬ optimist@0.3.4
│ └── wordwrap@0.0.2
├─┬ passport@0.1.17
│ ├── pause@0.0.1
│ └── pkginfo@0.2.3
├─┬ passport-facebook@1.0.0
│ └─┬ passport-oauth2@1.1.0
│   ├── oauth@0.9.10
│   ├── passport-strategy@1.0.0
│   └── uid2@0.0.3
├─┬ passport-google@0.3.0
│ ├─┬ passport-openid@0.3.1
│ │ └── openid@0.5.4
│ └── pkginfo@0.2.3
├─┬ passport-linkedin@0.1.3
│ ├─┬ passport-oauth@0.1.15
│ │ └── oauth@0.9.10
│ └── pkginfo@0.2.3
├─┬ passport-local@0.1.6
│ └── pkginfo@0.2.3
├─┬ passport-twitter@1.0.0
│ ├─┬ passport-oauth1@1.0.0
│ │ ├── oauth@0.9.10
│ │ ├── passport-strategy@1.0.0
│ │ └── utils-merge@1.0.0
│ └─┬ xtraverse@0.1.0
│   └── xmldom@0.1.16
├── password-hash@1.2.1
├─┬ sails@0.9.3
│ ├── async@0.2.9
│ ├── coffee-script@1.6.2
│ ├─┬ connect-mongo@0.3.2
│ │ └─┬ mongodb@1.2.14
│ │   └── bson@0.1.8
│ ├─┬ connect-redis@1.4.5
│ │ ├── debug@0.7.2
│ │ └── redis@0.7.3
│ ├── ejs@0.8.4
│ ├── ejs-locals@1.0.2
│ ├─┬ express@3.2.6
│ │ ├── buffer-crc32@0.2.1
│ │ ├── commander@0.6.1
│ │ ├─┬ connect@2.7.11
│ │ │ ├── bytes@0.2.0
│ │ │ ├── cookie@0.0.5
│ │ │ ├── formidable@1.0.14
│ │ │ ├── pause@0.0.1
│ │ │ ├── qs@0.6.5
│ │ │ └─┬ send@0.1.1
│ │ │   └── mime@1.2.11
│ │ ├── cookie@0.1.0
│ │ ├── cookie-signature@1.0.1
│ │ ├── debug@0.7.2
│ │ ├── fresh@0.1.0
│ │ ├── methods@0.0.1
│ │ ├── mkdirp@0.3.4
│ │ ├── range-parser@0.0.4
│ │ └─┬ send@0.1.0
│ │   └── mime@1.2.6
│ ├─┬ fs-extra@0.5.0
│ │ ├── jsonfile@0.0.1
│ │ ├── mkdirp@0.3.5
│ │ ├── ncp@0.2.7
│ │ └─┬ rimraf@2.1.4
│ │   └── graceful-fs@1.2.3
│ ├─┬ glob@3.1.14
│ │ ├── graceful-fs@1.1.14
│ │ ├── inherits@1.0.0
│ │ └─┬ minimatch@0.2.12
│ │   ├── lru-cache@2.3.0
│ │   └── sigmund@1.0.0
│ ├─┬ grunt@0.4.1
│ │ ├── async@0.1.22
│ │ ├── coffee-script@1.3.3
│ │ ├── colors@0.6.1
│ │ ├── dateformat@1.0.2-1.2.3
│ │ ├── eventemitter2@0.4.13
│ │ ├─┬ findup-sync@0.1.2
│ │ │ └── lodash@1.0.1
│ │ ├─┬ glob@3.1.21
│ │ │ ├── graceful-fs@1.2.3
│ │ │ └── inherits@1.0.0
│ │ ├── hooker@0.2.3
│ │ ├── iconv-lite@0.2.11
│ │ ├─┬ js-yaml@2.0.5
│ │ │ ├─┬ argparse@0.1.15
│ │ │ │ ├── underscore@1.4.4
│ │ │ │ └── underscore.string@2.3.3
│ │ │ └── esprima@1.0.3
│ │ ├── lodash@0.9.2
│ │ ├─┬ minimatch@0.2.12
│ │ │ ├── lru-cache@2.3.0
│ │ │ └── sigmund@1.0.0
│ │ ├─┬ nopt@1.0.10
│ │ │ └── abbrev@1.0.4
│ │ ├─┬ rimraf@2.0.3
│ │ │ └── graceful-fs@1.1.14
│ │ ├── underscore.string@2.2.1
│ │ └── which@1.0.5
│ ├─┬ grunt-cli@0.1.9
│ │ ├─┬ findup-sync@0.1.2
│ │ │ ├─┬ glob@3.1.21
│ │ │ │ ├── graceful-fs@1.2.3
│ │ │ │ ├── inherits@1.0.0
│ │ │ │ └─┬ minimatch@0.2.12
│ │ │ │   ├── lru-cache@2.3.0
│ │ │ │   └── sigmund@1.0.0
│ │ │ └── lodash@1.0.1
│ │ ├─┬ nopt@1.0.10
│ │ │ └── abbrev@1.0.4
│ │ └── resolve@0.3.1
│ ├── grunt-contrib-clean@0.4.1
│ ├── grunt-contrib-concat@0.3.0
│ ├── grunt-contrib-copy@0.4.1
│ ├─┬ grunt-contrib-cssmin@0.6.1
│ │ ├─┬ clean-css@1.0.12
│ │ │ └─┬ commander@1.3.2
│ │ │   └── keypress@0.1.0
│ │ └─┬ grunt-lib-contrib@0.6.1
│ │   └── zlib-browserify@0.0.1
│ ├─┬ grunt-contrib-jst@0.5.0
│ │ ├─┬ grunt-lib-contrib@0.5.3
│ │ │ └── zlib-browserify@0.0.1
│ │ └── lodash@1.0.1
│ ├─┬ grunt-contrib-less@0.5.2
│ │ └─┬ less@1.3.3
│ │   └── ycssmin@1.0.1
│ ├─┬ grunt-contrib-uglify@0.2.2
│ │ ├─┬ grunt-lib-contrib@0.6.1
│ │ │ └── zlib-browserify@0.0.1
│ │ └─┬ uglify-js@2.3.6
│ │   ├─┬ optimist@0.3.7
│ │   │ └── wordwrap@0.0.2
│ │   └─┬ source-map@0.1.28
│ │     └── amdefine@0.0.8
│ ├─┬ grunt-contrib-watch@0.4.4
│ │ ├─┬ gaze@0.3.4
│ │ │ ├── fileset@0.1.5
│ │ │ └─┬ minimatch@0.2.12
│ │ │   ├── lru-cache@2.3.0
│ │ │   └── sigmund@1.0.0
│ │ └─┬ tiny-lr@0.0.4
│ │   ├── debug@0.7.2
│ │   ├── faye-websocket@0.4.4
│ │   ├─┬ noptify@0.0.3
│ │   │ └─┬ nopt@2.0.0
│ │   │   └── abbrev@1.0.4
│ │   └── qs@0.5.6
│ ├── grunt-sails-linker@0.9.2
│ ├─┬ i18n@0.3.5
│ │ └── sprintf@0.1.1
│ ├─┬ include-all@0.1.1
│ │ └── underscore.string@2.3.1
│ ├── inflection@1.2.5
│ ├── lodash@1.2.1
│ ├── node-uuid@1.4.0
│ ├─┬ optimist@0.3.4
│ │ └── wordwrap@0.0.2
│ ├─┬ sails-disk@0.9.1
│ │ ├─┬ fs-extra@0.6.1
│ │ │ ├── jsonfile@0.0.1
│ │ │ ├── mkdirp@0.3.5
│ │ │ ├── ncp@0.4.2
│ │ │ └─┬ rimraf@2.1.4
│ │ │   └── graceful-fs@1.2.3
│ │ └── waterline-criteria@0.9.1
│ ├─┬ socket.io@0.9.14
│ │ ├── base64id@0.1.0
│ │ ├── policyfile@0.0.4
│ │ ├── redis@0.7.3
│ │ └─┬ socket.io-client@0.9.11
│ │   ├─┬ active-x-obfuscator@0.0.1
│ │   │ └── zeparser@0.0.5
│ │   ├── uglify-js@1.2.5
│ │   ├─┬ ws@0.4.28
│ │   │ ├── commander@0.6.1
│ │   │ ├── options@0.0.5
│ │   │ └── tinycolor@0.0.1
│ │   └── xmlhttprequest@1.4.2
│ ├── underscore.string@2.3.0
│ ├─┬ waterline@0.9.3
│ │ ├─┬ anchor@0.9.2
│ │ │ ├── async@0.2.6
│ │ │ └── validator@0.4.22
│ │ ├── q@0.9.4
│ │ └── underscore@1.4.4
│ └─┬ winston@0.7.1
│   ├── colors@0.6.1
│   ├── cycle@1.0.2
│   ├── eyes@0.1.8
│   ├── pkginfo@0.3.0
│   ├─┬ request@2.16.6
│   │ ├── aws-sign@0.2.0
│   │ ├── cookie-jar@0.2.0
│   │ ├── forever-agent@0.2.0
│   │ ├─┬ form-data@0.0.10
│   │ │ └─┬ combined-stream@0.0.4
│   │ │   └── delayed-stream@0.0.5
│   │ ├─┬ hawk@0.10.2
│   │ │ ├── boom@0.3.8
│   │ │ ├── cryptiles@0.1.3
│   │ │ ├── hoek@0.7.6
│   │ │ └── sntp@0.1.4
│   │ ├── json-stringify-safe@3.0.0
│   │ ├── mime@1.2.11
│   │ ├── oauth-sign@0.2.0
│   │ ├── qs@0.5.6
│   │ └── tunnel-agent@0.2.0
│   └── stack-trace@0.0.7
├─┬ sails-disk@0.9.1
│ ├─┬ fs-extra@0.6.1
│ │ ├── jsonfile@0.0.1
│ │ ├── mkdirp@0.3.5
│ │ ├── ncp@0.4.2
│ │ └─┬ rimraf@2.1.4
│ │   └── graceful-fs@1.2.3
│ ├── lodash@1.2.1
│ └── waterline-criteria@0.9.1
├─┬ sails-mongo@0.9.3
│ ├── async@0.2.9
│ ├─┬ mongodb@1.3.8
│ │ ├── bson@0.1.9
│ │ └── kerberos@0.0.3
│ ├── underscore@1.4.4
│ └── underscore.string@2.3.1
├─┬ smtp-tester@0.4.8 extraneous
│ ├── mimelib-noiconv@0.1.9
│ ├─┬ simplesmtp@0.3.8
│ │ ├── rai@0.1.7
│ │ └── xoauth2@0.1.8
│ └── underscore@1.5.1
└─┬ swig@1.0.0-pre2
  ├─┬ optimist@0.6.0
  │ ├── minimist@0.0.1
  │ └── wordwrap@0.0.2
  └─┬ uglify-js@2.3.6
    ├── async@0.2.9
    ├─┬ optimist@0.3.7
    │ └── wordwrap@0.0.2
    └─┬ source-map@0.1.28
      └── amdefine@0.0.8
npm ERR! extraneous: gravatar@1.0.6 /var/www/web/insights-platform/node_modules/gravatar
npm ERR! extraneous: mailer@0.6.7 /var/www/web/insights-platform/node_modules/mailer
npm ERR! extraneous: smtp-tester@0.4.8 /var/www/web/insights-platform/node_modules/smtp-tester
npm ERR! not ok code 0
deitch commented 11 years ago

The only difference I see is that simplesmtp is 0.3.7, and I usually run against 0.3.8. I cannot see how that would break it, but, if you want to try and see?

cd node_modules/nodemailer
npm rm simplesmtp
npm install simplesmtp@0.3.8
cd ../..

I don't believe it will matter, but never hurts to try. You can always revert by going back to the main directory and doing

npm rm nodemailer
npm install nodemailer
deitch commented 11 years ago

You comfortable with node-inspector?

lemannrus commented 11 years ago

Have not used it, I have to try. Reinstalling did not help

deitch commented 11 years ago

I didn't think it would, 0.3.7 to 0.3.8 is so minor, it shouldn't matter, but at some point the API in these mailers did change.

What mail server you using? Can you run it in debug mode so it will spit out what it receives and sends, so we can try to recreate?

lemannrus commented 11 years ago

I am using postfix. What should I do to run it in debug mode?

deitch commented 11 years ago

You can look in /var/log/mail.log to start, see what it reports on the error. Then I would do postfix -v start, run the connection, then pull out the logs and stop it again and restart. You don't want it in verbose mode for longer than necessary. See what it is reporting on the local attempted connection.

lemannrus commented 11 years ago

Sorry to deviate from the topic, but I did console.log(message) in pool.js and that's what I got - maybe it will help:

{ domain: null,
    at SMTPConnectionPool._onConnectionError (/var/www/web/insights-platform/node_modules/nodemailer/node_modules/simplesmtp/lib/pool.js:297:17)
  _events: {},
    at SMTPClient.EventEmitter.emit (events.js:95:17)
  _maxListeners: 10,
    at SMTPClient._onError (/var/www/web/insights-platform/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:319:10)
  options: 
    at Socket.EventEmitter.emit (events.js:95:17)
   { identityString: 'Nodemailer-0.5.2',
    at net.js:830:16
     charset: 'utf-8',
    at process._tickDomainCallback (node.js:459:13)
     escapeSMTP: true },
  _headers: 
   { 'MIME-Version': '1.0',
     'X-Mailer': 'Nodemailer (0.5.2; +http://www.nodemailer.com/)',
     Date: 'Wed, 04 Sep 2013 10:36:13 GMT',
     'Message-Id': '<1378290973157.58e42f46@Nodemailer>' },
  _message: 
   { from: '"Test" ',
     subject: 'Activate Email',
     body: 'This is where everything goes for activate. Please click on the following URL:\n\nhttp://insights-platform.dev/activate?code=8d250633&email=&user=1\n\nThanks!' },
  _alternatives: [],
  _attachments: [],
  _relatedAttachments: [],
  _envelope: { from: [ 'lemannrus@gmail.com' ] },
  _cacheOutput: false,
  _outputBuffer: '',
  _dkim: false,
  _gencounter: 0,
  _messageId: '1378290973157.58e42f46@Nodemailer',
  returnCallback: 
   [ { username: 'lemannrus@gmail.com',
       firstname: 'Alexander',
       lastname: 'Grigor',
       password: 'sha1$87f4dd1a$1$bf22334158924502d66de947dd7d814b86f5aee1',
       createdAt: Wed Sep 04 2013 13:36:13 GMT+0300 (EEST),
       updatedAt: Wed Sep 04 2013 13:36:13 GMT+0300 (EEST),
       id: 1,
       activation_code: '8d250633' } ] }
Process finished with exit code 8

returnCallback really is not a function

deitch commented 11 years ago

Ha! I was going to ask you to use node-inspector and put in breakpoints, but console.log is jus' fine.

No, it isn't. That looks like a user object!

deitch commented 11 years ago

By jove, I think I've got it!

lemannrus commented 11 years ago

Hmm... and what i should do?)

deitch commented 11 years ago

Wait. I need to check something.

deitch commented 11 years ago

Update to activator 0.2.4, and tell me what happens. Keep the console.log for first run so we can see.

lemannrus commented 11 years ago
{ domain: null,
  _events: {},
  _maxListeners: 10,
  options: 
   { identityString: 'Nodemailer-0.5.2',
     charset: 'utf-8',
     escapeSMTP: true },
  _headers: 
   { 'MIME-Version': '1.0',
     'X-Mailer': 'Nodemailer (0.5.2; +http://www.nodemailer.com/)',
     Date: 'Wed, 04 Sep 2013 11:04:26 GMT',
     'Message-Id': '<1378292666580.c2f3edef@Nodemailer>' },
  _message: 
   { from: '"Test" ',
     subject: 'Activate Email',
     body: 'This is where everything goes for activate. Please click on the following URL:\n\nhttp://insights-platform.dev/activate?code=9367878e&email=&user=1\n\nThanks!' },
  _alternatives: [],
  _attachments: [],
  _relatedAttachments: [],
  _envelope: { from: [ 'lemannrus@gmail.com' ] },
  _cacheOutput: false,
  _outputBuffer: '',
  _dkim: false,
  _gencounter: 0,
  _messageId: '1378292666580.c2f3edef@Nodemailer',
  returnCallback: [Function] }

I getting this: "{"code":"EADDRINFO","errno":"EADDRINFO","syscall":"getaddrinfo"}". Ah, this is my fault. I change host to "localhost" and getting this: {"name":"RecipientError","data":"250 2.1.0 Ok"}

deitch commented 11 years ago

Ah, but at least the returnCallback is now a function, so that part is working correctly. And it is returning the error.

deitch commented 11 years ago

EADDRINFO usually means that it could not find the address. It looks like the mail url you are using is var url = "smtp://alexander.localdomain:" + mailport + "/localhost/" + escape("Test lemannrus@gmail.com")

Are you sure that alexander.localdomain is resolvable? Did you try to dig it?

lemannrus commented 11 years ago

Yes, I wrote above that it was my fault. But the next problem is that there is no destination - {"name":"RecipientError","data":"250 2.1.0 Ok"}

deitch commented 11 years ago

You want to put a breakpoint or console.log at AuthController LL58, make sure that req.activator is actually set?

lemannrus commented 11 years ago

console.log returns this:

{ id: 1, body: 1 }
lemannrus commented 11 years ago

Maybe the problem is that the email is stored in the model with the name "username"? No, rename is did not help

deitch commented 11 years ago

Bingo. activator makes a (not always fair) assumption that the response to a find() will be a JS object, and that object will have a property email.

This should be a config override, but in the meantime, you can just do this:

model = {find: function (user, cb) {
    User.findOne({id: user}).done(function(err,res){
      res.email = res.username; // or however you retrieve the email
    });
}, save: function (id, data, cb) {
    User.update({id: id}, data).done(cb);
}}
lemannrus commented 11 years ago

Oh, god. Now my application simply hangs up after form submitting

deitch commented 11 years ago

Install 0.2.5. It includes a way to override the email property name. https://github.com/deitch/activator#initialization

deitch commented 11 years ago

Hangs up? Error?

lemannrus commented 11 years ago

YES, IT'S WORKED!Thank you)

deitch commented 11 years ago

We probably made an error in adjusting that adapter. Much better to have it native.