/var/www/myprog.com.ua/server/node/objects
Edit: /var/www/myprog.com.ua/server/node/objects/session.js (1623B)
const User = require('../objects/user');
class Session {
constructor(client_key, socket) {
this.key = null; //client_key
//this.operator = null;
//this.driver = null;
//this.user = null;
this.user = null;
this.socket = null;
this.type = null;
this.host = null;
this.login = false;
this.ver = null;
if (client_key) {
this.key = client_key;
}
if (socket) {
this.socket = socket;
}
}
set_user(user) {
if (user) {
console.debug('Session::set_user()::' + user.id);
this.user = user;
this.type = WHO.USER.VALUE;
}
}
set_host(host) {
if (host) {
console.debug('Session::set_host()::' + host.id);
this.host = host;
this.type = WHO.HOST.VALUE;
}
}
get_user() {
return this.user;
}
is_host() {
if (this.host!=null && this.host.id && this.host.id > 0) {
return true;
} else {
return false;
}
}
is_user() {
if (this.user.id && this.user.id > 0) {
return true;
} else {
return false;
}
}
is_activated() {
if (this.user) {
return this.user.is_activated();
} else {
return false;
}
}
is_admin() {
if (this.user) {
return this.user.is_admin();
} else {
return false;
}
}
}
module.exports = Session;