Ver a proveniência

modding #1805: Added the onBeforeGetAccountInfo modding event

tags/v0.10.0^2
Shaun há 2 anos
ascendente
cometimento
13a290185d
4 ficheiros alterados com 27 adições e 19 eliminações
  1. +18
    -3
      src/server/components/auth.js
  2. +3
    -3
      src/server/components/extensions/socialCommands.js
  3. +2
    -2
      src/server/components/social/canChat.js
  4. +4
    -11
      src/server/security/restEndpoints/forceSaveAll.js

+ 18
- 3
src/server/components/auth.js Ver ficheiro

@@ -286,26 +286,37 @@ module.exports = {
},

onLogin: async function (msg, storedPassword, err, compareResult) {
const { data: { username } } = msg;

if (!compareResult) {
msg.callback(messages.login.incorrect);
return;
}
this.username = msg.data.username;
this.username = username;
cons.logOut(this.obj);

this.initTracker();

await this.getSkins();

this.accountInfo = await io.getAsync({
key: msg.data.username,
const accountInfo = await io.getAsync({
key: username,
table: 'accountInfo',
noDefault: true
}) || {
loginStreak: 0
};

const msgAccountInfo = {
username,
accountInfo
};

events.emit('onBeforeGetAccountInfo', msgAccountInfo);

this.accountInfo = msgAccountInfo.accountInfo;

msg.callback();
},

@@ -544,5 +555,9 @@ module.exports = {
dead: true
}
});
},

getAccountLevel: function () {
return this.accountInfo.level;
}
};

+ 3
- 3
src/server/components/extensions/socialCommands.js Ver ficheiro

@@ -96,7 +96,7 @@ module.exports = {
});

this.actions = chatCommandConfig.contextActions
.filter(c => this.obj.auth.accountLevel >= commandRoles[c.command]);
.filter(c => this.obj.auth.getAccountLevel() >= commandRoles[c.command]);
},

onBeforeChat: function (msg) {
@@ -120,7 +120,7 @@ module.exports = {
}]
});
return;
} else if (this.obj.auth.accountLevel < commandRoles[actionName]) {
} else if (this.obj.auth.getAccountLevel() < commandRoles[actionName]) {
this.obj.socket.emit('events', {
onGetMessages: [{
messages: [{
@@ -317,7 +317,7 @@ module.exports = {
const msg = [
'You can use the following commands:',
...Object.keys(commandRoles)
.filter(c => this.obj.auth.accountLevel >= commandRoles[c])
.filter(c => this.obj.auth.getAccountLevel() >= commandRoles[c])
.map(c => `/${c}`)
].join('<br />');


+ 2
- 2
src/server/components/social/canChat.js Ver ficheiro

@@ -1,6 +1,6 @@
module.exports = (obj, time) => {
const roleLevel = obj.auth.accountLevel;
if (roleLevel >= 5)
const accountLevel = obj.auth.getAccountLevel();
if (accountLevel >= 5)
return true;

if (!time)


+ 4
- 11
src/server/security/restEndpoints/forceSaveAll.js Ver ficheiro

@@ -4,19 +4,12 @@ const doSaveAll = async (res, config, err, compareResult) => {
if (!compareResult)
return;

const char = await io.getAsync({
table: 'character',
const accountInfo = await io.getAsync({
table: 'accountInfo',
key: config.username
});

if (!char)
return;

const auth = (char.components || []).find(c => c.type === 'auth');
if (!auth)
return;

if (auth.accountLevel < 9)
if (!accountInfo || !accountInfo.level || accountInfo.level < 9)
return;

await atlas.returnWhenZonesIdle();
@@ -50,7 +43,7 @@ module.exports = async (req, res, next) => {
.join(' ');
});

if (['msg', 'username', 'pwd', 'character'].some(p => !config[p]))
if (['msg', 'username', 'pwd'].some(p => !config[p]))
return;

let storedPassword = await io.getAsync({


Carregando…
Cancelar
Guardar