diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 05:59:14 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 05:59:47 +0100 |
| commit | 5dadac51b65c714e2235f28c000a646716e2a63a (patch) | |
| tree | d6ddf369addae2a02979bdb81a645778f30d94b4 | |
| parent | 3b0cde84d5186693dd48c9f136a47480b3c23c89 (diff) | |
also make mailboxes
| -rw-r--r-- | bucky/db/index.js | 1 | ||||
| -rw-r--r-- | bucky/util/auth.js | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js index 9e01e9b..c2cf947 100644 --- a/bucky/db/index.js +++ b/bucky/db/index.js @@ -192,6 +192,7 @@ db.getMailboxCounts = function(boxes){ return knex.column('mbox').count('* as count').select().from('messages').where('mbox', 'in', boxes).groupBy('mbox') } db.createMailbox = function(data){ + return new db.Mailbox(data).save() } /* MESSAGES */ diff --git a/bucky/util/auth.js b/bucky/util/auth.js index 548ffcc..dd3df6f 100644 --- a/bucky/util/auth.js +++ b/bucky/util/auth.js @@ -56,6 +56,29 @@ var auth = module.exports = { } db.createUser(data).then(() => next()) }, + function (req, res, next) { + var username = req.user.get('username') + Promise.all([ + db.createMailbox({ + mbox: username + '.inbox', + owner: username, + mcount: 0, + editable: 0, + }), + db.createMailbox({ + mbox: username + '.outbox', + owner: username, + mcount: 0, + editable: 0, + }), + db.createMailbox({ + mbox: username + '.drafts', + owner: username, + mcount: 0, + editable: 1, + }), + ]).then(() => next()) + }, passport.authenticate("local"), auth.login) app.put("/api/login", |
