Skip to content

Commit

Permalink
Import page .authme rollback file support #152
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Nov 13, 2021
1 parent e1ab6f8 commit 4ecb0a3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
38 changes: 31 additions & 7 deletions app/import/src/js/ga.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,28 @@ const gaImport = () => {
.then(() => {
dialog
.showSaveDialog({
title: "Save import file",
filters: [{ name: "Text file", extensions: ["txt"] }],
defaultPath: "~/authme_import.txt",
title: "Save Authme file",
filters: [{ name: "Authme file", extensions: ["authme"] }],
defaultPath: "~/import.authme",
})
.then((result) => {
canceled = result.canceled
output = result.filePath

/**
* .authme import file
* @type {LibAuthmeFile}
*/
const save_file = {
role: "import",
encrypted: false,
codes: Buffer.from(str).toString("base64"),
date: time.timestamp(),
version: 3,
}

if (canceled === false) {
fs.writeFile(output, str, (err) => {
fs.writeFile(output, JSON.stringify(save_file, null, "\t"), (err) => {
if (err) {
logger.error(`Error creating file - ${err}`)
} else {
Expand Down Expand Up @@ -188,16 +200,28 @@ const gaCamera = () => {
.then(() => {
dialog
.showSaveDialog({
title: "Save Authme import file",
filters: [{ name: "Authme import file", extensions: ["authme"] }],
title: "Save Authme file",
filters: [{ name: "Authme file", extensions: ["authme"] }],
defaultPath: "~/import.authme",
})
.then((result) => {
canceled = result.canceled
output = result.filePath

/**
* .authme import file
* @type {LibAuthmeFile}
*/
const save_file = {
role: "import",
encrypted: false,
codes: Buffer.from(string).toString("base64"),
date: time.timestamp(),
version: 3,
}

if (canceled === false) {
fs.writeFile(output, string, (err) => {
fs.writeFile(output, JSON.stringify(save_file, null, "\t"), (err) => {
if (err) {
logger.error(`Error creating file - ${err}`)
} else {
Expand Down
40 changes: 32 additions & 8 deletions app/import/src/js/qr.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,28 @@ const qrImport = () => {
.then(() => {
dialog
.showSaveDialog({
title: "Save import file",
filters: [{ name: "Text file", extensions: ["txt"] }],
defaultPath: "~/authme_import.txt",
title: "Save file",
filters: [{ name: "Authme file", extensions: ["authme"] }],
defaultPath: "~/import.authme",
})
.then((result) => {
canceled = result.canceled
output = result.filePath

/**
* .authme import file
* @type {LibAuthmeFile}
*/
const save_file = {
role: "import",
encrypted: false,
codes: Buffer.from(str).toString("base64"),
date: time.timestamp(),
version: 3,
}

if (canceled === false) {
fs.writeFile(output, str, (err) => {
fs.writeFile(output, JSON.stringify(save_file, null, "\t"), (err) => {
if (err) {
logger.error(`Error creating file - ${err}`)
} else {
Expand Down Expand Up @@ -194,16 +206,28 @@ const qrCamera = () => {
.then(() => {
dialog
.showSaveDialog({
title: "Save import file",
filters: [{ name: "Text file", extensions: ["txt"] }],
defaultPath: "~/authme_import.txt",
title: "Save file",
filters: [{ name: "Authme file", extensions: ["authme"] }],
defaultPath: "~/import.authme",
})
.then((result) => {
canceled = result.canceled
output = result.filePath

/**
* .authme import file
* @type {LibAuthmeFile}
*/
const save_file = {
role: "import",
encrypted: false,
codes: Buffer.from(str).toString("base64"),
date: time.timestamp(),
version: 3,
}

if (canceled === false) {
fs.writeFile(output, str, (err) => {
fs.writeFile(output, JSON.stringify(save_file, null, "\t"), (err) => {
if (err) {
logger.error(`Error creating file - ${err}`)
} else {
Expand Down

0 comments on commit 4ecb0a3

Please sign in to comment.