mirror of
https://github.com/jsbin/jsbin.git
synced 2026-02-01 16:46:05 +00:00
Add ability to update email address
This implementation is not going to scale well :/
This commit is contained in:
parent
8c73544225
commit
684bdba638
@ -154,8 +154,8 @@ MySQL.prototype = {
|
||||
},
|
||||
getUser: function (id, fn) {
|
||||
this.connection.query(templates.getUser, [id], function (err, results) {
|
||||
if (err || !results.length) {
|
||||
return fn(!err && !results.length ? 'not-found' : err);
|
||||
if (err) {
|
||||
return fn(err);
|
||||
}
|
||||
fn(null, results[0]);
|
||||
});
|
||||
@ -194,12 +194,20 @@ MySQL.prototype = {
|
||||
fn(null, results.insertId);
|
||||
});
|
||||
},
|
||||
updateUserEmail: function (id, email, fn) {
|
||||
this.connection.query(templates.updateUserEmail, [email, id], function (err, results) {
|
||||
if (err) {
|
||||
return fn(err);
|
||||
}
|
||||
fn(null);
|
||||
});
|
||||
},
|
||||
updateUserKey: function (id, key, fn) {
|
||||
this.connection.query(templates.updateUserKey, [key, id], function (err, results) {
|
||||
if (err || !results.affectedRows) {
|
||||
return fn(!err && !results.length ? 'not-found' : err);
|
||||
if (err) {
|
||||
return fn(err);
|
||||
}
|
||||
fn(null, results.insertId);
|
||||
fn(null);
|
||||
});
|
||||
},
|
||||
getUserByForgotToken: function (token, fn) {
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
"getUserByEmail": "SELECT * FROM `ownership` WHERE `email`=? LIMIT 1",
|
||||
"setUser": "INSERT INTO `ownership` (`name`, `key`, `email`, `last_login`, `created`, `updated`) VALUES (?, ?, ?, NOW(), NOW(), NOW())",
|
||||
"touchLogin": "UPDATE `ownership` SET `last_login`=NOW() WHERE `name`=?",
|
||||
"updateUserKey": "UPDATE ownership SET `key`=?, `created`=NOW(), `updated`=NOW() WHERE `name`=?",
|
||||
"updateUserEmail": "UPDATE ownership SET `email`=?, `updated`=NOW() WHERE `name`=?",
|
||||
"updateUserKey": "UPDATE ownership SET `key`=?, `updated`=NOW() WHERE `name`=?",
|
||||
"setBinForUser": "INSERT INTO `owners` (`name`, `url`, `revision`) VALUES (?, ?, ?)",
|
||||
"getBinsByUser": "SELECT `url`, `revision` FROM `owners` WHERE `name`=? ORDER BY `url`, `revision` DESC",
|
||||
"getBinByUrlAndRevision": "SELECT * FROM `sandbox` WHERE `url`=? AND `revision`=? LIMIT 1",
|
||||
|
||||
@ -18,6 +18,7 @@ var methods = [
|
||||
'getUserByEmail',
|
||||
'setUser',
|
||||
'touchLogin',
|
||||
'updateUserEmail',
|
||||
'updateUserKey',
|
||||
'getUserByForgotToken',
|
||||
'setForgotToken',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user