Ah fuck. I had to bind the callback:

UserSchema.methods.hasEqualPassword = function(password, callback) {
    crypto.pbkdf2(password, this.salt, 25000, 512, function(err, 
encodedPassword) {
        if (err) throw err;
        var hasEqualPassword = (this.password == encodedPassword);
        console.log(hasEqualPassword);
        callback(hasEqualPassword, encodedPassword);
    }*.bind(this)*);
};

@ryandesign

I could't prove this. Now it is working but it seems that there is a lot 
work done on the crypto api (and it's documentation). 
Encoding the generated password to base64 is still on the todo but I think 
I have to wait the bug report until I get closer information

Am Samstag, 21. Juli 2012 03:51:44 UTC+2 schrieb ryandesign:
>
> This reminds me of a problem I had last year. I was comparing two values 
> that came from MongoDB, and I didn't realize that MongoDB was wrapping them 
> in another object. Though they were the same strings, they were different 
> objects, so a normal JavaScript comparison failed, until I used toString(): 
>
> https://groups.google.com/d/msg/express-js/Hb1-zUJwnSk/1nqUI_JqXi0J 
>
>
> On Jul 20, 2012, at 13:03, kyogron wrote: 
>
> > When rehashing the user login password and encoding it with the same 
> parameters I do a === this always returns false. 
> > 
> > To test if this is not an issue of the logic I persisted the rehashed 
> password to database and compared manuelly. Result they are equal. 
> > 
> > Question is just why javascirpt doesn't see this. I think it has issue 
> with such "strings". I started a issue on github because of the toString() 
> method on pbkdf2 
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to