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 => {
|
||||
if (response.status == 404) {
|
||||
throw DoesNotExistError;
|
||||
}
|
||||
return response.json();
|
||||
}).then(data => {
|
||||
return data.data.keys;
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from "./pageUtils.js";
|
||||
import { PageState } from "./PageState.js";
|
||||
import { makeElement } from "./htmlUtils.js";
|
||||
import { getSealStatus } from './api.js';
|
||||
|
||||
import {
|
||||
HomePage,
|
||||
|
@ -36,8 +37,6 @@ import {
|
|||
PwGenPage,
|
||||
} from "./pages";
|
||||
|
||||
import { getSealStatus } from './api.js';
|
||||
|
||||
const pages = {
|
||||
HOME: new HomePage(),
|
||||
TOTP: new TOTPViewPage(),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 { CopyableInputBox } from "../../elements/CopyableInputBox.js";
|
||||
import { makeElement } from "../../htmlUtils.js";
|
||||
|
@ -43,7 +43,15 @@ export class TOTPViewPage extends Page {
|
|||
this.refreshers.push(setInterval(totpRefresher, 3000, totpKeyName, totpListElement));
|
||||
}, this);
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue