Add error message when no TOTP codes have been added.
This commit is contained in:
parent
3ba6beca89
commit
b2c75cf1e6
|
@ -323,6 +323,9 @@ export async function getTOTPKeys(baseMount) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return fetch(request).then(response => {
|
return fetch(request).then(response => {
|
||||||
|
if (response.status == 404) {
|
||||||
|
throw DoesNotExistError;
|
||||||
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
return data.data.keys;
|
return data.data.keys;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import {
|
||||||
} from "./pageUtils.js";
|
} from "./pageUtils.js";
|
||||||
import { PageState } from "./PageState.js";
|
import { PageState } from "./PageState.js";
|
||||||
import { makeElement } from "./htmlUtils.js";
|
import { makeElement } from "./htmlUtils.js";
|
||||||
|
import { getSealStatus } from './api.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
HomePage,
|
HomePage,
|
||||||
|
@ -36,8 +37,6 @@ import {
|
||||||
PwGenPage,
|
PwGenPage,
|
||||||
} from "./pages";
|
} from "./pages";
|
||||||
|
|
||||||
import { getSealStatus } from './api.js';
|
|
||||||
|
|
||||||
const pages = {
|
const pages = {
|
||||||
HOME: new HomePage(),
|
HOME: new HomePage(),
|
||||||
TOTP: new TOTPViewPage(),
|
TOTP: new TOTPViewPage(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Page } from "../../types/Page.js";
|
import { Page } from "../../types/Page.js";
|
||||||
import { getTOTPKeys, getTOTPCode } from "../../api.js";
|
import { getTOTPKeys, getTOTPCode, DoesNotExistError } from "../../api.js";
|
||||||
import { setTitleElement, setPageContent, changePage } from "../../pageUtils.js";
|
import { setTitleElement, setPageContent, changePage } from "../../pageUtils.js";
|
||||||
import { CopyableInputBox } from "../../elements/CopyableInputBox.js";
|
import { CopyableInputBox } from "../../elements/CopyableInputBox.js";
|
||||||
import { makeElement } from "../../htmlUtils.js";
|
import { makeElement } from "../../htmlUtils.js";
|
||||||
|
@ -43,7 +43,15 @@ export class TOTPViewPage extends Page {
|
||||||
this.refreshers.push(setInterval(totpRefresher, 3000, totpKeyName, totpListElement));
|
this.refreshers.push(setInterval(totpRefresher, 3000, totpKeyName, totpListElement));
|
||||||
}, this);
|
}, this);
|
||||||
document.getElementById("loadingText").remove();
|
document.getElementById("loadingText").remove();
|
||||||
|
}).catch(e => {
|
||||||
|
if (e == DoesNotExistError) {
|
||||||
|
let loadingText = document.getElementById("loadingText");
|
||||||
|
loadingText.innerText = "You seem to have no TOTP codes here, would you like to create one?";
|
||||||
|
} else {
|
||||||
|
setErrorText(e.message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
|
Loading…
Reference in a new issue