fix: added validation for links

This commit is contained in:
Pavel-Savely Savianok 2025-02-09 20:54:10 +03:00
parent 589a9cb527
commit b4df58765d
2 changed files with 8 additions and 2 deletions

View File

@ -5,13 +5,19 @@ let _props = null;
AppSettingsPage({
build(props) {
_props = props;
const storage = props.settingsStorage.getItem("TOTPs") ?? []
const totpEntrys = GetTOTPList(storage)
const createButton = TextInput({
placeholder: "otpauth://",
label: "Add new OTP Link",
onChange: (changes) => {
storage.push(getTOTPByLink(changes))
var link = getTOTPByLink(changes)
if(link == null){
console.log("link is invalid")
return;
}
storage.push(link)
updateStorage(storage)
},
labelStyle: {

View File

@ -33,7 +33,7 @@ export function getTOTPByLink(link) {
getHashType(algorithm)
);
} catch (err) {
throw new Error("Link is not valid");
return null;
}
}