Prevent type error with the new admin script

This commit is contained in:
yflory 2023-01-12 15:54:16 +01:00
parent 07d21d03a5
commit a0714b9cc8
2 changed files with 4 additions and 1 deletions

View File

@ -779,12 +779,14 @@ var commands = {
// addFirstAdmin is an anon_rpc command
Admin.addFirstAdmin = function (Env, data, cb) {
if (!Env.installToken) { return void cb('EINVAL'); }
var token = data.token;
if (!token || !data.edPublic) { return void cb('MISSING_ARGS'); }
if (token.length !== 64 || data.edPublic.length !== 44) { return void cb('INVALID_ARGS'); }
if (token !== Env.installToken) { return void cb('FORBIDDEN'); }
if (Array.isArray(Env.admins) && Env.admins.length) { return void cb('EEXISTS'); }
var key = data.edPublic;
if (token.length !== 64 || data.edPublic.length !== 44) { return void cb('INVALID_ARGS'); }
adminDecree(Env, null, function (err) {
if (err) { return void cb(err); }

View File

@ -167,6 +167,7 @@ module.exports.create = function (config) {
limits: {},
admins: [],
installToken: undefined,
WARN: function (e, output) { // TODO deprecate this
if (!Env.Log) { return; }
if (e && output) {