Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
forward the newsletter preference from the client and check for dupli…
Browse files Browse the repository at this point in the history
…cate email
  • Loading branch information
zaach committed Dec 13, 2012
1 parent 7f926cd commit 1b7aa4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/client.js
Expand Up @@ -87,7 +87,7 @@ GombotClient.prototype = {
password: args.pass
}, function(err, r) {
self.authKey = r.authKey;
args.data = JSON.stringify({email: args.email, pass: r.authKey});
args.data = JSON.stringify({email: args.email, pass: r.authKey, newsletter: args.newsletter});
// send request with authKey as the password
request(args, cb);
});
Expand Down
23 changes: 13 additions & 10 deletions lib/db/couchbase.js
Expand Up @@ -33,16 +33,19 @@ module.exports = {
return this;
},
stageAccount: function(data, cb) {
var account = {
pass: data.pass,
email: data.email,
newsletter: !!data.newsletter,
staged: true
};
db.set(data.email, account, function (err, meta) {
console.log('meta', meta);
if (err) cb(err);
else cb(null, meta);
db.get(data.email, function (err, doc, meta) {
if (doc) return cb("That email has already been used");
var account = {
pass: data.pass,
email: data.email,
newsletter: !!data.newsletter,
staged: false
};
db.set(data.email, account, function (err, meta) {
console.log('meta', meta);
if (err) cb(err);
else cb(null, meta);
});
});
return this;
},
Expand Down

0 comments on commit 1b7aa4c

Please sign in to comment.