2fa fixes

This commit is contained in:
Mathium05 committed 2026-10-01 18:20:54 -05:00
1 parent ab112a78bc
commit c8644f212e
3 files changed
+20 -11

No files matched your search

+2 -9
View File
@@ -1,5 +1,5 @@
import {BinWrite} from "../utils/binaryUtils.js";
import {setTheme} from "../utils/utils.js";
import {saveFile, setTheme} from "../utils/utils.js";
import {Play} from "./play.js";
if (window.location.pathname.startsWith("/audio")) {
await setTheme();
@@ -179,14 +179,7 @@ if(zip){
const download = document.getElementById("download");
if (download) {
download.onclick = () => {
const blob = new Blob([buff], {type: "binary"});
const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = downloadUrl;
a.download = "sounds.jasf";
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(downloadUrl);
saveFile(buff, "sounds.jasf");
};
}
}
+8 -2
View File
@@ -15,7 +15,7 @@ import {
setPreferences,
ThemeOption,
} from "./utils/storage/userPreferences";
import {createImg, getapiurls, installPGet, setTheme, SW} from "./utils/utils";
import {createImg, getapiurls, installPGet, saveFile, setTheme, SW} from "./utils/utils";
export async function showusersettings(localuser: Localuser) {
const prefs = getPreferences();
@@ -840,8 +840,14 @@ export async function showusersettings(localuser: Localuser) {
break;
}
} else {
gen2FA();
const codes = _.backup_codes as {
user_id: string;
code: string;
consumed: boolean;
}[];
saveFile(new TextEncoder().encode(JSON.stringify(codes)).buffer, "codes.backup");
localuser.mfa_enabled = true;
gen2FA();
twofa.returnFromSub();
}
},
+10
View File
@@ -1012,3 +1012,13 @@ export function getInstances() {
export function getStringURLMapPair() {
return [stringURLMap, stringURLsMap] as const;
}
export async function saveFile(buff: ArrayBuffer, name: string) {
const blob = new Blob([buff], {type: "binary"});
const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = downloadUrl;
a.download = name;
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(downloadUrl);
}