Add getOwner
This commit is contained in:
@@ -6,6 +6,7 @@ exports = module.exports = {
|
||||
getByEmail: getByEmail,
|
||||
getByAccessToken: getByAccessToken,
|
||||
getByResetToken: getByResetToken,
|
||||
getOwner: getOwner,
|
||||
getAll: getAll,
|
||||
getAllAdmins: getAllAdmins,
|
||||
add: add,
|
||||
@@ -56,6 +57,18 @@ function getByEmail(email, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getOwner(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
// the first created user it the admin
|
||||
database.query('SELECT ' + USERS_FIELDS + ' FROM users WHERE admin=1 ORDER BY createdAt LIMIT 1', function (error, result) {
|
||||
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
|
||||
if (result.length === 0) return callback(new DatabaseError(DatabaseError.NOT_FOUND));
|
||||
|
||||
callback(null, result[0]);
|
||||
});
|
||||
}
|
||||
|
||||
function getByResetToken(resetToken, callback) {
|
||||
assert.strictEqual(typeof resetToken, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
Reference in New Issue
Block a user