last day (15 days later) » 

21:29
okay so I can't figure this out. but maybe I can just explain the problem by showing you (you helped me figure out most of the auth stuff with passport thus far)
okay so my form has <input type="checkbox" name="foo" />
after validation foo is set to true of false (in req.body)
db.updatePreferences(req.body)
then I pass the req.body to the db module
module.exports.updatePreferences = function(data) {
    return pg.connectAsync(connString).bind({}).spread(function(client, close) {
        this.close = close;
        return client.queryAsync('UPDATE subscribers SET email = $1, company_name = $2, contact_name = $3, phone = $4, can_email = $5, can_sms = $6, email_limit = $7, sms_limit = $8 WHERE username = $9', [data.email, data.company_name, data.contact_name, data.phone, data.can_email, data.can_sms, data.email_limit, data.sms_limit, data.username]);
and I use this ugly ass code to update the db
21:33
and there you can see the basic auth code
so my question is: the auth code is run on login, after the preferences are saved on the db how do I then merge the new data to request.user object
without having to logout and re login
...weird
I haven't seen passport stuff wrapped in db connections like that
	passport.serializeUser(function(user, done) {
		done(null, user);
	});
I'm pretty sure that was a mix of you and Florian helping me
why aren't you using id there?
didn't work when I used id
I guess that works?
21:38
yup
except when changing stuff
lemme see app.js?
it's... uhh.. a huge mess :P
see it?
@SomeKittensUx2666
nvm just see the history
after logging in goto /preferences
change a value, save, go back to that page
log out, log back in, see the change
app.post('/preferences', function(req, res) {
    req.body.username = req.user.username;
    // validate data
    // ......
    // ......
    req.body.can_sms = 'can_sms' in req.body;
    req.body.can_email = 'can_email' in req.body;
    console.log(req.body); // all looks good here
    if( !valid ) { // this isn't the issue
        res.redirect('/preferences?error');
    } else {
        db.updatePreferences(req.body).then(function() {
            res.redirect('/dashboard');
        });
    }
});
21:42
that is from my app.js
any ideas?
what version of express?
3.4.8
hmm.
  passport.serializeUser(function(user, done) {
    done(null, user.id);
  });

  passport.deserializeUser(function(id, done) {
    client.query('SELECT * FROM subscribers WHERE id = $1', [id], function(err, res) {
      if( err ) {
        return done(err);
      }
      done(null, res.rows[0]);
    });
  });
What does that change?
22:11
I can't remember why I needed that now :P
it's been a while.
fuck.
22:46
i seriously can't remember why it is there :/

last day (15 days later) »