1
0
Fork 0

Add error message when no TOTP codes have been added.

This commit is contained in:
Kitteh 2021-04-17 11:42:06 +01:00
parent 3ba6beca89
commit b2c75cf1e6
3 changed files with 13 additions and 3 deletions

View file

@ -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;

View file

@ -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(),

View file

@ -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() {