Skip to content

Commit

Permalink
Remove export text file
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Feb 11, 2022
1 parent eedc30f commit f6b2ddd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 62 deletions.
38 changes: 11 additions & 27 deletions app/export/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
</head>
<body>
<!-- build number -->
<div class="w-full text-white bg-black font-bold build hidden z-10 top-0 sticky">
<div class="container flex flex-row items-center justify-center py-2 mx-auto">
<div class="build sticky top-0 z-10 hidden w-full bg-black font-bold text-white">
<div class="container mx-auto flex flex-row items-center justify-center py-2">
<div class="flex">
<h5 class="mx-3 flex flex-row m-0 font-bold build-content text-center">You are running a pre release version of Authme!</h5>
<h5 class="build-content m-0 mx-3 flex flex-row text-center font-bold">You are running a pre release version of Authme!</h5>
</div>
</div>
</div>

<!-- header -->
<div class="mx-auto rounded-2xl bg-gray-700 w-3/5 mt-40 text-center">
<img src="../../img/header.png" class="h-16 w-16 relative top-5" />
<div class="mx-auto mt-40 w-3/5 rounded-2xl bg-gray-700 text-center">
<img src="../../img/header.png" class="relative top-5 h-16 w-16" />
<h2>Export</h2>
<h4 data-loc>You can export the 2FA codes you saved.</h4>
<button class="buttoni mb-6" onclick="hide()">
Expand All @@ -34,9 +34,9 @@ <h4 data-loc>You can export the 2FA codes you saved.</h4>
</div>

<!-- content -->
<div class="bg-gray-700 w-3/5 m-auto mt-20 mb-60 rounded-2xl relative text-center p-1">
<div class="relative m-auto mt-20 mb-60 w-3/5 rounded-2xl bg-gray-700 p-1 text-center">
<!-- before export -->
<div class="before_export mx-auto rounded-2xl bg-gray-800 w-2/3 mt-20 mb-20">
<div class="before_export mx-auto mt-20 mb-20 w-2/3 rounded-2xl bg-gray-800 pb-1">
<h3 data-loc class="pt-5">Export codes</h3>
<h4 data-loc>If you saved your codes you can export the secrets and the saved QR codes.</h4>
<button class="buttoni but1 mb-5" id="but0" onclick="exportCodes()">
Expand All @@ -48,12 +48,12 @@ <h4 data-loc>If you saved your codes you can export the secrets and the saved QR
</div>
<!-- after export -->
<div class="after_export hidden">
<div class="mx-auto rounded-2xl bg-gray-800 w-2/3 mt-20 mb-20">
<div class="mx-auto mt-20 mb-20 w-2/3 rounded-2xl bg-gray-800">
<h3 data-loc class="pt-5">Save exported codes</h3>
<h4 data-loc>Save your exported 2FA codes to use it elsewhere.</h4>
<div class="flex flex-row justify-center gap-3 flex-wrap">
<div class="flex flex-row flex-wrap justify-center gap-3">
<div>
<button class="buttoni" id="but1" onclick="newSaveFile()">
<button class="buttoni" id="but1" onclick="saveFile()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2" />
</svg>
Expand All @@ -68,25 +68,9 @@ <h5 data-loc class="m-3">Ideal to import for Authme or other Authme apps.</h5>
</svg>
<span data-loc>Export .html file</span>
</button>
<h5 data-loc class="m-3">Ideal for scanning the QR codes or for security backup.</h5>
<h5 data-loc class="m-3 mb-8">Ideal for scanning the QR codes or for security backup.</h5>
</div>
</div>

<!-- advanced -->
<div class="mx-auto p-3">
<details class="details mb-5 transform ease-in duration-200">
<summary class="summary font-bold mb-3 cursor-pointer">More options</summary>
<div>
<button class="buttoni" id="but1" onclick="saveFile()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2" />
</svg>
Export .txt file
</button>
<h5 class="m-3">The old way to import for Authme or other Authme apps.</h5>
</div>
</details>
</div>
</div>
</div>
</div>
Expand Down
39 changes: 5 additions & 34 deletions app/export/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ const settings_refresher = setInterval(() => {
* Process data from saved file
* @param {String} text
*/
const processdata = (text) => {
const processData = (text) => {
const converted = convert.fromText(text, 0)

go(converted)
createElements(converted)
}

/**
* Start creating export elements
* @param {LibImportFile} data
*/
const go = (data) => {
const createElements = (data) => {
const names = data.names
const secrets = data.secrets
const issuers = data.issuers
Expand All @@ -121,39 +121,10 @@ const go = (data) => {
}
}

/**
* Save .txt file
*/
const saveFile = () => {
dialog
.showSaveDialog({
title: lang.import_dialog.save_file,
filters: [{ name: lang.export_dialog.text_file, extensions: ["txt"] }],
defaultPath: "~/authme_export.txt",
})
.then((result) => {
canceled = result.canceled
output = result.filePath

if (canceled === false) {
fs.writeFile(output, file, (err) => {
if (err) {
return logger.error(`Error creating file - ${err}`)
} else {
return logger.log("Text file created")
}
})
}
})
.catch((err) => {
logger.error(`Failed to save - ${err}`)
})
}

/**
* Save .authme file
*/
const newSaveFile = () => {
const saveFile = () => {
dialog
.showSaveDialog({
title: lang.import_dialog.save_file,
Expand Down Expand Up @@ -286,7 +257,7 @@ const exportCodes = async () => {

const decrypted = aes.decrypt(Buffer.from(codes_file.codes, "base64"), key)

processdata(decrypted.toString())
processData(decrypted.toString())
file = decrypted.toString()

decrypted.fill(0)
Expand Down
Loading

0 comments on commit f6b2ddd

Please sign in to comment.