Skip to content

Commit

Permalink
deployer: add ctx var for the master identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Dec 10, 2020
1 parent 2745592 commit 0a54a5e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [x] deployer: add variable input stage
- [x] blur some inputs
- [x] persist user oauth data and refresh it on social login
- [x] deployer: add a context var for the master admin identifiers
- [ ] add tool to import ban from other databases
- [ ] deployer: on download_github, first query to see which is the default branch
- [ ] improve setup page common template incompatibility behavior and set $engine to 2
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
author 'Tabarra'
description 'Remotely Manage & Monitor your GTA5 FiveM Server'
repository 'https://github.com/tabarra/txAdmin'
version '3.1.0-beta'
version '3.1.0-beta2'

fx_version 'bodacious'
games { 'gta5' }
Expand Down
20 changes: 17 additions & 3 deletions src/webroutes/deployer/actions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//Requires
const modulename = 'WebServer:DeployerActions';
const fs = require('fs-extra');
const slash = require('slash');
const path = require('path');
const cloneDeep = require('lodash/cloneDeep');
const slash = require('slash');
const { dir, log, logOk, logWarn, logError } = require('../../extras/console')(modulename);
const helpers = require('../../extras/helpers');

Expand Down Expand Up @@ -86,18 +87,31 @@ async function handleSetVariables(ctx) {
if(isUndefined(ctx.request.body.svLicense)){
return ctx.utils.error(400, 'Invalid Request - missing parameters');
}
const userVars = ctx.request.body;
const userVars = cloneDeep(ctx.request.body);

//Setting iden
if(typeof userVars.dbDelete !== 'undefined'){
userVars.dbDelete = (userVars.dbDelete === 'true');
userVars.dbConnectionString = (userVars.dbPassword.length)
? `mysql://${userVars.dbUsername}:${userVars.dbPassword}@${userVars.dbHost}/${userVars.dbName}?charset=utf8mb4`
: `mysql://${userVars.dbUsername}@${userVars.dbHost}/${userVars.dbName}?charset=utf8mb4`;
}

//Setting identifiers array
const admin = globals.authenticator.getAdminByName(ctx.session.auth.username);
if(!admin) return ctx.send({type: 'danger', message: "Admin not found."});
const addPrincipalLines = [];
Object.keys(admin.providers).forEach(providerName => {
if(admin.providers[providerName].identifier){
addPrincipalLines.push(`add_principal identifier.${admin.providers[providerName].identifier} group.admin`);
}
});
userVars.addPrincipalsMaster = addPrincipalLines.join('\n');

//Start deployer
try {
ctx.utils.logAction(`Running recipe.`);
globals.deployer.start(ctx.request.body)
globals.deployer.start(userVars)
} catch (error) {
return ctx.send({type: 'danger', message: error.message});
}
Expand Down

0 comments on commit 0a54a5e

Please sign in to comment.