mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
+5
-1
@@ -48,6 +48,7 @@ const COLUMN_FIELDS = ["id", "username", "salt", "hash", "createdAt"];
|
||||
const SESSION_FIELDS = ["accountType", "isGuide", "isModerator", "membershipDays", "startInDen", "startRoom"];
|
||||
const DEFAULT_MEMBERSHIP_DAYS = 9999;
|
||||
const MAX_ACCOUNT_TYPE = 5;
|
||||
const MEMBERSHIP_TYPES = [0, 2]; // non-member, member
|
||||
const MAX_MEMBERSHIP_DAYS = 99999;
|
||||
|
||||
const USERNAME_PATTERN = /^[A-Za-z0-9 .-]{3,20}$/;
|
||||
@@ -244,7 +245,10 @@ const MAX_START_ROOM = 80;
|
||||
function setLoginChoices(account, choices) {
|
||||
const asked = config.loginChoices && choices && typeof choices === "object" ? choices : {};
|
||||
const whole = (value, max) => Number.isInteger(value) && value >= 0 && value <= max;
|
||||
account.accountType = whole(asked.accountType, MAX_ACCOUNT_TYPE) ? asked.accountType : config.defaultAccountType;
|
||||
// member or not is the player's own choice on any server, the rest only
|
||||
// with config.loginChoices: another account type shows to everyone.
|
||||
const type = choices && typeof choices === "object" && MEMBERSHIP_TYPES.includes(choices.accountType) ? choices.accountType : asked.accountType;
|
||||
account.accountType = whole(type, MAX_ACCOUNT_TYPE) ? type : config.defaultAccountType;
|
||||
account.isGuide = asked.isGuide === true;
|
||||
account.isModerator = asked.isModerator === true;
|
||||
account.membershipDays = whole(asked.membershipDays, MAX_MEMBERSHIP_DAYS) ? asked.membershipDays : DEFAULT_MEMBERSHIP_DAYS;
|
||||
|
||||
Reference in new issue
Block a user