Finished of cloud backup and restore feature

This commit is contained in:
Alicia Sykes
2021-05-24 20:46:58 +01:00
parent 0e43e91d84
commit 5b729cfbdd
6 changed files with 41 additions and 22 deletions

View File

@@ -3,14 +3,10 @@
<div class="section intro">
<h2>Cloud Backup & Restore</h2>
<p class="intro">
The cloud backup and restore feature, allows you to upload your config to the internet,
and then restore it on any other device or instance of Dashy. This provides an alternative
method of configuring, without the need to write YAML, and also means you don't necessarily
need to host your own instance of the application.
Cloud backup and restore is an optional feature, that enabled you to upload your
config to the internet, and then restore it on any other device or instance of Dashy.
<br><br>
All data is fully end-to-end encrypted with AES, using your password as the key.
Both encryption and decryption happens on your device so your data cannot be
accessed by anyone other than you.
</p>
</div>
<div class="section backup-section">
@@ -102,7 +98,7 @@ export default {
} else if (savedHash === this.makeHash(this.backupPassword)) {
this.makeUpdate();
} else {
this.showErrorMsg('Incorrect password. Please enter the password you used last time.');
this.showErrorMsg('Incorrect password. Please enter your current password.');
}
},
makeBackup() {

View File

@@ -60,7 +60,9 @@ export default {
pageInfo.title = this.formElements.title;
pageInfo.description = this.formElements.description;
pageInfo.footerText = this.formElements.footerText;
pageInfo.navLinks = this.formElements.navLinks.filter(link => (link.title !== ''));
if (this.formElements.navLinks) {
pageInfo.navLinks = this.formElements.navLinks.filter(link => (link.title !== ''));
}
localStorage.setItem(localStorageKeys.PAGE_INFO, JSON.stringify(pageInfo));
this.$toasted.show('Changes saved succesfully');
setTimeout(() => { location.reload(); }, 1500); // eslint-disable-line no-restricted-globals

View File

@@ -2,8 +2,9 @@ import sha256 from 'crypto-js/sha256';
import aes from 'crypto-js/aes';
import Utf8 from 'crypto-js/enc-utf8';
import axios from 'axios';
import { backupEndpoint } from '@/utils/defaults';
const ENDPOINT = 'https://dashy-sync-service.as93.net';
const ENDPOINT = backupEndpoint; // 'https://dashy-sync-service.as93.net';
/* Stringify, encrypt and encode data for transmission */
const encryptData = (data, password) => {
@@ -36,6 +37,7 @@ const encodeGetParams = p => Object.entries(p).map(kv => kv.map(encodeURICompone
/* Restores the backup */
export const restore = (backupId, password) => {
const params = encodeGetParams({ backupId, subHash: makeSubHash(password) });
console.log(makeSubHash(password));
const url = `${ENDPOINT}/?${params}`;
return new Promise((resolve, reject) => {
axios.get(url).then((response) => {

View File

@@ -62,4 +62,5 @@ module.exports = {
className: 'toast-message',
iconPack: 'fontawesome',
},
backupEndpoint: 'https://dashy-sync-service.as93.net',
};