Initial support for user status flags (NotAvail, NotVisible, ...)

This commit is contained in:
Bryan Ashby
2022-05-08 22:15:57 -06:00
parent 24491000ad
commit 6502f3b55e
5 changed files with 62 additions and 14 deletions

View File

@@ -23,8 +23,6 @@ const moment = require('moment');
const sanatizeFilename = require('sanitize-filename');
const ssh2 = require('ssh2');
exports.isRootUserId = function(id) { return 1 === id; };
module.exports = class User {
constructor() {
this.userId = 0;
@@ -32,6 +30,7 @@ module.exports = class User {
this.properties = {}; // name:value
this.groups = []; // group membership(s)
this.authFactor = User.AuthFactors.None;
this.statusFlags = User.StatusFlags.None;
}
// static property accessors
@@ -73,6 +72,14 @@ module.exports = class User {
};
}
static get StatusFlags() {
return {
None : 0x00000000,
NotAvailable : 0x00000001, // Not currently available for chat, message, page, etc.
NotVisible : 0x00000002, // Invisible -- does not show online, last callers, etc.
}
}
isAuthenticated() {
return true === this.authenticated;
}
@@ -121,6 +128,22 @@ module.exports = class User {
return sanatizeFilename(name) || `user${this.userId.toString()}`;
}
isAvailable() {
return (this.statusFlags & User.StatusFlags.NotAvailable) == 0;
}
isVisible() {
return (this.statusFlags & User.StatusFlags.NotVisible) == 0;
}
setVisibility(visible) {
if (visible) {
this.statusFlags &= ~User.StatusFlags.NotVisible;
} else {
this.statusFlags |= User.StatusFlags.NotVisible;
}
}
getLegacySecurityLevel() {
if(this.isRoot() || this.isGroupMember('sysops')) {
return 100;