source now in separate modules;
Implemented MQTT coms. Using Tasmota for ESP8266; IR working reliably
This commit is contained in:
28
src/db/users.js
Normal file
28
src/db/users.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var records = [
|
||||
{ id: 1, username: 'me', password: 'A23', displayName: 'admin', emails: [ { value: 'jack@example.com' } ] }
|
||||
, { id: 2, username: 'db', password: 'doby', displayName: 'DB', emails: [ { value: 'jill@example.com' } ] }
|
||||
, { id: 3, username: 'popov', password: 'Zelenakrav@', displayName: 'Doby', emails: [ { value: 'db@example.com' } ] }
|
||||
];
|
||||
|
||||
exports.findById = function(id, cb) {
|
||||
process.nextTick(function() {
|
||||
var idx = id - 1;
|
||||
if (records[idx]) {
|
||||
cb(null, records[idx]);
|
||||
} else {
|
||||
cb(new Error('User ' + id + ' does not exist'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exports.findByUsername = function(username, cb) {
|
||||
process.nextTick(function() {
|
||||
for (var i = 0, len = records.length; i < len; i++) {
|
||||
var record = records[i];
|
||||
if (record.username === username) {
|
||||
return cb(null, record);
|
||||
}
|
||||
}
|
||||
return cb(null, null);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user