fix: added validation for links
This commit is contained in:
parent
589a9cb527
commit
b4df58765d
@ -5,13 +5,19 @@ let _props = null;
|
|||||||
AppSettingsPage({
|
AppSettingsPage({
|
||||||
build(props) {
|
build(props) {
|
||||||
_props = props;
|
_props = props;
|
||||||
|
|
||||||
const storage = props.settingsStorage.getItem("TOTPs") ?? []
|
const storage = props.settingsStorage.getItem("TOTPs") ?? []
|
||||||
const totpEntrys = GetTOTPList(storage)
|
const totpEntrys = GetTOTPList(storage)
|
||||||
const createButton = TextInput({
|
const createButton = TextInput({
|
||||||
placeholder: "otpauth://",
|
placeholder: "otpauth://",
|
||||||
label: "Add new OTP Link",
|
label: "Add new OTP Link",
|
||||||
onChange: (changes) => {
|
onChange: (changes) => {
|
||||||
storage.push(getTOTPByLink(changes))
|
var link = getTOTPByLink(changes)
|
||||||
|
if(link == null){
|
||||||
|
console.log("link is invalid")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
storage.push(link)
|
||||||
updateStorage(storage)
|
updateStorage(storage)
|
||||||
},
|
},
|
||||||
labelStyle: {
|
labelStyle: {
|
||||||
|
@ -33,7 +33,7 @@ export function getTOTPByLink(link) {
|
|||||||
getHashType(algorithm)
|
getHashType(algorithm)
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error("Link is not valid");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user