Update Central API Key Creation

api-key-management-upgrades
Moe 2025-02-10 16:04:16 -08:00
parent 1883f8f2e9
commit 936f14cad9
2 changed files with 10 additions and 9 deletions

View File

@ -6,7 +6,7 @@ module.exports = (s,config,lang) => {
} = require('../../system/utils.js')(config)
const {
getConnectionDetails,
} = require('./connectDetails.js')(s,config)
} = require('./connectDetails.js')(s,config,lang)
const configPath = process.cwd() + '/conf.json'
async function startWorker(){
if(!config.userHasSubscribed){

View File

@ -1,6 +1,7 @@
const fs = require("fs").promises
module.exports = (s,config) => {
const configPath = config.thisIsDocker ? "/config/super.json" : s.location.super;
module.exports = (s,config,lang) => {
const { getNewApiKey } = require('../../user/apiKeys.js')(s,config,lang)
const configPath = s.location.super;
const requiredApiKeyPermissions = {
"auth_socket": "1",
"create_api_keys": "1",
@ -91,16 +92,16 @@ module.exports = (s,config) => {
return suitableKey;
}
async function createApiKey(groupKey, userId){
const newApiKey = s.gid(30);
const newApiKey = await getNewApiKey(groupKey);
await s.knexQueryPromise({
action: "insert",
table: "API",
insert: {
ke : groupKey,
uid : userId,
code : newApiKey,
ip : '0.0.0.0',
details : s.stringJSON(requiredApiKeyPermissions)
ke: groupKey,
uid: userId,
code: newApiKey,
ip: '0.0.0.0',
details: s.stringJSON(requiredApiKeyPermissions)
}
});
return newApiKey