Removed password from firmware updates
This commit is contained in:
@@ -132,7 +132,6 @@ module.exports = new Vue({
|
||||
checkedUpgrade: false,
|
||||
firmwareName: '',
|
||||
latestVersion: '',
|
||||
password: '',
|
||||
ipAddress: '0.0.0.0',
|
||||
wifiSSID: '',
|
||||
confirmShutdown: false,
|
||||
@@ -140,7 +139,6 @@ module.exports = new Vue({
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
components: {
|
||||
'estop': { template: '#estop-template' },
|
||||
'loading-view': { template: '<h1>Loading...</h1>' },
|
||||
@@ -158,11 +156,14 @@ module.exports = new Vue({
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
events: {
|
||||
'config-changed': function () {this.modified = true;},
|
||||
'hostname-changed': function (hostname) {this.hostname = hostname},
|
||||
'config-changed': function () {
|
||||
this.modified = true;
|
||||
},
|
||||
|
||||
'hostname-changed': function (hostname) {
|
||||
this.hostname = hostname
|
||||
},
|
||||
|
||||
send: function (msg) {
|
||||
if (this.status == 'connected') {
|
||||
@@ -171,10 +172,13 @@ module.exports = new Vue({
|
||||
}
|
||||
},
|
||||
|
||||
connected: function () {
|
||||
this.update()
|
||||
},
|
||||
|
||||
connected: function () {this.update()},
|
||||
update: function () {this.update()},
|
||||
|
||||
update: function () {
|
||||
this.update()
|
||||
},
|
||||
|
||||
check: function () {
|
||||
this.latestVersion = '';
|
||||
@@ -191,28 +195,25 @@ module.exports = new Vue({
|
||||
}.bind(this))
|
||||
},
|
||||
|
||||
|
||||
upgrade: function () {
|
||||
this.password = '';
|
||||
this.confirmUpgrade = true;
|
||||
},
|
||||
|
||||
|
||||
upload: function (firmware) {
|
||||
this.firmware = firmware;
|
||||
this.firmwareName = firmware.name;
|
||||
this.password = '';
|
||||
this.confirmUpload = true;
|
||||
},
|
||||
|
||||
|
||||
error: function (msg) {
|
||||
// Honor user error blocking
|
||||
if (Date.now() - this.errorTimeoutStart < this.errorTimeout * 1000)
|
||||
return;
|
||||
|
||||
// Wait at least 1 sec to pop up repeated errors
|
||||
if (1 < msg.repeat && Date.now() - msg.ts < 1000) return;
|
||||
if (1 < msg.repeat && Date.now() - msg.ts < 1000) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Popup error dialog
|
||||
this.errorShow = true;
|
||||
@@ -220,75 +221,70 @@ module.exports = new Vue({
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
computed: {
|
||||
popupMessages: function () {
|
||||
var msgs = [];
|
||||
const msgs = [];
|
||||
|
||||
for (var i = 0; i < this.state.messages.length; i++) {
|
||||
var text = this.state.messages[i].text;
|
||||
if (!/^#/.test(text)) msgs.push(text);
|
||||
for (let i = 0; i < this.state.messages.length; i++) {
|
||||
const text = this.state.messages[i].text;
|
||||
if (!/^#/.test(text)) {
|
||||
msgs.push(text);
|
||||
}
|
||||
}
|
||||
|
||||
return msgs;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
ready: function () {
|
||||
$(window).on('hashchange', this.parse_hash);
|
||||
this.connect();
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
metric: function () {return this.config.settings.units != 'IMPERIAL'},
|
||||
|
||||
metric: function () {
|
||||
return this.config.settings.units != 'IMPERIAL'
|
||||
},
|
||||
|
||||
block_error_dialog: function () {
|
||||
this.errorTimeoutStart = Date.now();
|
||||
this.errorShow = false;
|
||||
},
|
||||
|
||||
|
||||
toggle_video: function (e) {
|
||||
if (this.video_size == 'small') this.video_size = 'large';
|
||||
else if (this.video_size == 'large') this.video_size = 'small';
|
||||
cookie.set('video-size', this.video_size);
|
||||
},
|
||||
|
||||
|
||||
toggle_crosshair: function (e) {
|
||||
e.preventDefault();
|
||||
this.crosshair = !this.crosshair;
|
||||
cookie.set('crosshair', this.crosshair);
|
||||
},
|
||||
|
||||
|
||||
estop: function () {
|
||||
if (this.state.xx == 'ESTOPPED') api.put('clear');
|
||||
else api.put('estop');
|
||||
},
|
||||
|
||||
|
||||
upgrade_confirmed: function () {
|
||||
upgrade_confirmed: async function () {
|
||||
this.confirmUpgrade = false;
|
||||
|
||||
api.put('upgrade', {password: this.password}).done(function () {
|
||||
try {
|
||||
await api.put('upgrade');
|
||||
this.firmwareUpgrading = true;
|
||||
|
||||
}.bind(this)).fail(function () {
|
||||
api.alert('Invalid password');
|
||||
}.bind(this))
|
||||
} catch (err) {
|
||||
api.alert('Error during upgrade.');
|
||||
console.error("Error during upgrade", err);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
upload_confirmed: function () {
|
||||
this.confirmUpload = false;
|
||||
|
||||
var form = new FormData();
|
||||
const form = new FormData();
|
||||
form.append('firmware', this.firmware);
|
||||
if (this.password) form.append('password', this.password);
|
||||
|
||||
$.ajax({
|
||||
url: '/api/firmware/update',
|
||||
@@ -300,13 +296,12 @@ module.exports = new Vue({
|
||||
|
||||
}).success(function () {
|
||||
this.firmwareUpgrading = true;
|
||||
|
||||
}.bind(this)).error(function () {
|
||||
api.alert('Invalid password or bad firmware');
|
||||
}.bind(this)).error(function (err) {
|
||||
api.alert('Firmware update failed');
|
||||
console.error('Firmware update failed', err);
|
||||
}.bind(this))
|
||||
},
|
||||
|
||||
|
||||
show_upgrade: function () {
|
||||
if (!this.latestVersion) return false;
|
||||
return is_newer_version(this.config.version, this.latestVersion);
|
||||
@@ -361,20 +356,6 @@ module.exports = new Vue({
|
||||
}.bind(this))
|
||||
},
|
||||
|
||||
// check_disk_space : function() {
|
||||
// $.ajax({
|
||||
// type: 'GET',
|
||||
// url: 'diskinfo.txt',
|
||||
// data: {hid: this.state.hid},
|
||||
// cache: false
|
||||
//
|
||||
// }).done(function (data) {
|
||||
// console.debug('>', data);
|
||||
// this.diskSpace = data;
|
||||
// this.$broadcast('diskSpace', data);
|
||||
// }.bind(this))
|
||||
// },
|
||||
|
||||
get_ip_address: function () {
|
||||
console.debug('get_ip>', this.ipAddress);
|
||||
return this.ipAddress;
|
||||
@@ -385,11 +366,6 @@ module.exports = new Vue({
|
||||
return this.wifiSSID;
|
||||
},
|
||||
|
||||
// get_disk_space : function() {
|
||||
// console.debug('get_disk>', this.diskSpace);
|
||||
// return this.diskSpace;
|
||||
// },
|
||||
|
||||
shutdown: function () {
|
||||
this.confirmShutdown = false;
|
||||
api.put('shutdown');
|
||||
@@ -456,7 +432,6 @@ module.exports = new Vue({
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
parse_hash: function () {
|
||||
var hash = location.hash.substr(1);
|
||||
|
||||
@@ -472,7 +447,6 @@ module.exports = new Vue({
|
||||
this.currentView = parts[0];
|
||||
},
|
||||
|
||||
|
||||
save: function () {
|
||||
api.put('config/save', this.config).done(function (data) {
|
||||
this.modified = false;
|
||||
@@ -481,7 +455,6 @@ module.exports = new Vue({
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
close_messages: function (action) {
|
||||
if (action == 'stop') api.put('stop');
|
||||
if (action == 'continue') api.put('unpause');
|
||||
|
||||
@@ -160,11 +160,6 @@ html(lang="en")
|
||||
| Are you sure you want to upgrade the firmware to version
|
||||
| {{latestVersion}}?
|
||||
|
||||
p.pure-control-group
|
||||
label(for="pass") Password
|
||||
input(name="pass", v-model="password", type="password",
|
||||
@keyup.enter="upgrade_confirmed")
|
||||
|
||||
div(slot="footer")
|
||||
button.pure-button(@click="confirmUpgrade=false") Cancel
|
||||
button.pure-button.pure-button-primary(@click="upgrade_confirmed")
|
||||
@@ -175,11 +170,6 @@ html(lang="en")
|
||||
div(slot="body")
|
||||
p Are you sure you want to upload firmware #[em {{firmwareName}}]?
|
||||
|
||||
p.pure-control-group
|
||||
label(for="pass") Password
|
||||
input(name="pass", v-model="password", type="password",
|
||||
@keyup.enter="upload_confirmed")
|
||||
|
||||
div(slot="footer")
|
||||
button.pure-button(@click="confirmUpload=false") Cancel
|
||||
button.pure-button.pure-button-primary(@click="upload_confirmed")
|
||||
|
||||
@@ -257,14 +257,9 @@ class FirmwareUpdateHandler(bbctrl.APIHandler):
|
||||
|
||||
|
||||
def put_ok(self):
|
||||
if not 'password' in self.request.arguments:
|
||||
raise HTTPError(401, 'Missing "password"')
|
||||
|
||||
if not 'firmware' in self.request.files:
|
||||
raise HTTPError(401, 'Missing "firmware"')
|
||||
|
||||
check_password(self.request.arguments['password'][0])
|
||||
|
||||
firmware = self.request.files['firmware'][0]
|
||||
|
||||
if not os.path.exists('firmware'): os.mkdir('firmware')
|
||||
@@ -278,7 +273,6 @@ class FirmwareUpdateHandler(bbctrl.APIHandler):
|
||||
|
||||
class UpgradeHandler(bbctrl.APIHandler):
|
||||
def put_ok(self):
|
||||
check_password(self.json['password'])
|
||||
self.get_ctrl().lcd.goodbye('Upgrading firmware')
|
||||
subprocess.Popen(['/usr/local/bin/upgrade-bbctrl'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user