* User.isGroupMember() can now take a string or array of strings to check

* Add WELCOME2.ANS
* Disallow "all" as a username
* Check group membership when switching areas
This commit is contained in:
Bryan Ashby 2015-11-04 23:04:55 -07:00
parent d2866df97f
commit 5bd95255a3
6 changed files with 22 additions and 7 deletions

View File

@ -83,7 +83,7 @@ function getDefaultConfig() {
newUserNames : [ 'new', 'apply' ], // Names reserved for applying
// :TODO: Mystic uses TRASHCAN.DAT for this -- is there a reason to support something like that?
badUserNames : [ 'sysop', 'admin', 'administrator', 'root' ],
badUserNames : [ 'sysop', 'admin', 'administrator', 'root', 'all' ],
},
// :TODO: better name for "defaults"... which is redundant here!

View File

@ -78,8 +78,13 @@ function changeMessageArea(client, areaName, cb) {
}
},
function validateAccess(area, callback) {
// :TODO: validate user has access to |area| -- must belong to group(s) specified
if(_.isArray(area.groups) && !
client.user.isGroupMember(area.groups))
{
callback(new Error('User does not have access to this area'));
} else {
callback(null, area);
}
},
function changeArea(area, callback) {
client.user.persistProperty('message_area_name', area.name, function persisted(err) {

View File

@ -48,8 +48,18 @@ function User() {
this.isSysOp = this.isRoot; // alias
this.isGroupMember = function(groupName) {
return self.groups.indexOf(groupName) > -1;
this.isGroupMember = function(groupNames) {
if(_.isString(groupNames)) {
groupNames = [ groupNames ];
}
groupNames.forEach(function groupEntry(groupName) {
if(-1 === self.groups.indexOf(groupName)) {
return false;
}
});
return true;
};
this.getLegacySecurityLevel = function() {

BIN
mods/art/WELCOME2.ANS Normal file

Binary file not shown.

View File

@ -1066,7 +1066,7 @@
}
{
value: { 1: 1 }
action: @menu:messageArea
action: @systemMethod:prevMenu
}
{
value: { 1: 2 }

View File

@ -144,7 +144,7 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
to : mle.toUserName,
ts : moment(mle.modTimestamp).format(dateTimeFormat),
newIndicator : mle.messageId > self.lastReadId ? newIndicator : '',
}
};
}
msgListView.setItems(_.map(self.messageList, function formatMsgListEntry(mle) {