Add PV[name,value] ACS check

This commit is contained in:
Bryan Ashby 2020-06-15 19:28:32 -06:00
parent 9e9dc9af89
commit dd08cd68e7
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
4 changed files with 19 additions and 1 deletions

View File

@ -3,6 +3,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
## 0.0.12-beta
* The `master` branch has become mainline. What this means to users is `git pull` will always give you the latest and greatest. Make sure to read [Updating](/docs/admin/updating.md) and keep an eye on `WHATSNEW.md` (this file) and [UPGRADE](UPGRADE.md)! See also [ticket #276](https://github.com/NuSkooler/enigma-bbs/issues/276).
* New `PV` ACS check for arbitrary user properties. See [ACS](/docs/configuration/acs.md) for details.
## 0.0.11-beta
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!

View File

@ -1055,6 +1055,14 @@ function peg$parse(input, options) {
}
const points = user.getPropertyAsNumber(UserProps.AchievementTotalPoints) || 0;
return !isNan(value) && points >= value;
},
PV : function userPropValue() {
if (!user || !Array.isArray(value) || value.length !== 2) {
return false;
}
const [propName, propValue] = value;
const actualPropValue = user.getProperty(propName);
return actualPropValue === propValue;
}
}[acsCode](value);
} catch (e) {

View File

@ -39,6 +39,7 @@ The following are ACS codes available as of this writing:
| AP<i>achievementPoints</i> | User has >= _achievementPoints_ achievement points |
| AF<i>authFactor</i> | User's current *Authentication Factor* is >= _authFactor_. Authentication factor 1 refers to username + password (or PubKey) while factor 2 refers to 2FA such as One-Time-Password authentication. |
| AR<i>authFactorReq</i> | Current user **requires** an Authentication Factor >= _authFactorReq_ |
| PV[_name,_value_] | Checks that the property by _name_ for the current user is exactly _value_. This ACS allows arbitrary user property values to be checked. For example, `PV[message_conf,local]` checks that the user is currently in the "local" message conference.
## ACS Strings
ACS strings are one or more ACS codes in addition to some basic language semantics.

View File

@ -211,6 +211,14 @@
}
const points = user.getPropertyAsNumber(UserProps.AchievementTotalPoints) || 0;
return !isNan(value) && points >= value;
},
PV : function userPropValue() {
if (!user || !Array.isArray(value) || value.length !== 2) {
return false;
}
const [propName, propValue] = value;
const actualPropValue = user.getProperty(propName);
return actualPropValue === propValue;
}
}[acsCode](value);
} catch (e) {