/var/www/myprog.com.ua/server/node/objects
Edit: /var/www/myprog.com.ua/server/node/objects/user.js (1296B)
const microtime = require('../helpers/date');
class User {
constructor(data) {
// db fields
this.id = 0;
this.login = 0;
this.name = 'новый пользователь';
this.pass = '';
this.key = null;
this.reg_date = null;
this.last_date = null;
this.active = 0;
this.email = '';
this.deleted = 0;
this.rule = 0;
// set order data from db
if (data) {
for (var i in this) {
if (data[i]) {
this[i] = data[i];
console.log('client add '+i+' = '+data[i]);
}
}
}
}
is_activated(){
return this.active==1?true:false;
}
is_admin(){
return this.rule==1?true:false;
}
get_id() {
return parseInt(this.id);
}
set_id(value) {
if (this.id != value) {
this.id = parseInt(value);
}
}
get_key() {
return this.key;
}
get_name() {
return this.name;
}
set_name(val) {
if (val) {
this.name = val;
}
}
get_value(key) {
return this[key];
}
set_value(key, val) {
this[key] = val;
}
}
module.exports = User;