Skip to content

Commit

Permalink
[change] All query with pass to env.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Zarubin committed Oct 26, 2024
1 parent 2779dbf commit 9a4b46b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Subscribe and like!

[![Version](https://img.shields.io/badge/deb_package-0.0.5-blue)](https://github.com/keygenqt/aurora-toolbox/releases)
[![Version](https://img.shields.io/badge/deb_package-0.0.6-blue)](https://github.com/keygenqt/aurora-toolbox/releases)

![Preview](https://raw.githubusercontent.com/keygenqt/aurora-toolbox/refs/heads/main/files/images/preview.png)

Expand Down
2 changes: 1 addition & 1 deletion data/ui/dialogs/AboutDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<property name="presentation-mode">floating</property>
<property name="application-icon">com.keygenqt.aurora-toolbox</property>
<property name="application-name" translatable="yes">Aurora Toolbox</property>
<property name="version">0.0.5</property>
<property name="version">0.0.6</property>
<property name="copyright">© 2024 KeyGenQt</property>
<property name="issue_url">https://github.com/keygenqt/aurora-toolbox/issues</property>
<property name="developer-name" translatable="yes">Vitaliy Zarubin</property>
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hide:
#### Install

```shell
sudo dpkg -i aurora-toolbox_0.0.5-1_amd64.deb
sudo dpkg -i aurora-toolbox_0.0.6-1_amd64.deb
```

#### Install dependency
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Define our project
project(
'aurora-toolbox',
version: '0.0.5',
version: '0.0.6',
license: ['Apache 2.0'],
meson_version: '>= 0.59.0',
default_options: ['cpp_std=c++17', 'cpp_rtti=false', 'cpp_eh=none',
Expand Down
2 changes: 1 addition & 1 deletion scripts/deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ dpkg -x $FOLDER/$DEB_FOLDER.deb $FOLDER/$DEB_FOLDER

# Install / Remove
sudo dpkg -r com.keygenqt.aurora-toolbox
sudo dpkg -i release/aurora-toolbox_0.0.5-1_amd64.deb
sudo dpkg -i release/aurora-toolbox_0.0.6-1_amd64.deb
41 changes: 25 additions & 16 deletions src/base/connectors/ShellExec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';

import { Log } from '../utils/Log.js';

export const ShellExec = {
/**
* Execute command async multiple response
Expand All @@ -27,9 +25,9 @@ export const ShellExec = {
* @param {function} reject - call error
*/
communicateCallback(query = [], resolve = function(v) {}, reject = function(e) {}) {
Log.debug(query);
try {
const arg = Gio.SubprocessFlags.STDIN_PIPE | Gio.SubprocessFlags.STDOUT_PIPE;
query = ShellExec._setPassword(query);
const subProcess = Gio.Subprocess.new(query, arg);
// @todo
// get_stdout_pipe
Expand Down Expand Up @@ -82,18 +80,7 @@ export const ShellExec = {
return new Promise((resolve, _) => {
try {
const arg = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE;

if (query[query.length-1].includes('password')) {
// Get password
const password = query[query.length-1].split('?')[1].split('&').filter((e) => e.includes('password'))[0].split('=')[1];
// Remove password from query
query[query.length-1] = query[query.length-1]
.replace(`&password=${password}`, '')
.replace(`?password=${password}`, '')
// Set env
GLib.setenv('cli_password', password, true);
}

query = ShellExec._setPassword(query);
const subProcess = Gio.Subprocess.new(query, arg);
subProcess.communicate_utf8_async(null, null, (proc, res) => {
let [success, stdout, stderr] = proc?.communicate_utf8_finish(res);
Expand All @@ -115,7 +102,7 @@ export const ShellExec = {
* @returns Data response from API json
*/
communicateSync(query = []) {
Log.debug(query);
query = ShellExec._setPassword(query);
try {
const arg = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE;
const subProcess = Gio.Subprocess.new(query, arg);
Expand All @@ -128,4 +115,26 @@ export const ShellExec = {
return null;
}
},
/**
* Set password to env
*
* @param {*} query
* @returns Query without password
*/
_setPassword(query) {
if (query[query.length-1].includes('password')) {
// Get password
const password = query[query.length-1].split('?')[1].split('&').filter((e) => e.includes('password'))[0].split('=')[1];
// Remove password from query
query[query.length-1] = query[query.length-1]
.replace(`&password=${password}`, '')
.replace(`?password=${password}`, '')
// Set env
GLib.setenv('cli_password', password, true);
console.log('--------------------')
console.log(query)
console.log('--------------------')
}
return query;
}
}

0 comments on commit 9a4b46b

Please sign in to comment.