2FA totp, bugfix

This commit is contained in:
2024-04-07 14:23:59 +02:00
parent e97ac34365
commit 0974ac9260
21 changed files with 262 additions and 106 deletions

View File

@@ -12,7 +12,7 @@ import {
export default function Dialog(props) {
const show = props.show;
const show = !!props.show;
const onClose = props.onClose || function() { };
const onOption = props.onOption || function() { };
const options = props.options || ["Close"];
@@ -36,7 +36,13 @@ export default function Dialog(props) {
for (const [index, name] of options.entries()) {
buttons.push(
<Button variant={"outlined"} size={"small"} key={"button-" + name}
onClick={() => { onClose(); onOption(index, inputData); setInputData({}); }}>
onClick={() => {
let res = onOption(index, inputData);
if (res || res === undefined) {
onClose();
setInputData({});
}
}}>
{name}
</Button>
)
@@ -54,16 +60,21 @@ export default function Dialog(props) {
inputElements.push(<span {...inputProps}>{input.value}</span>);
break;
case 'text':
case 'password':
case 'number':
case 'password': {
let onChange = (input.type === "number") ?
e => setInputData({ ...inputData, [input.name]: e.target.value.replace(/[^0-9,.]/, '') }) :
e => setInputData({ ...inputData, [input.name]: e.target.value });
inputElements.push(<TextField
{...inputProps}
type={input.type}
type={input.type === "number" ? "text" : input.type}
size={"small"} fullWidth={true}
key={"input-" + input.name}
value={inputData[input.name] || ""}
onChange={e => setInputData({ ...inputData, [input.name]: e.target.value })}
onChange={onChange}
/>)
break;
} break;
case 'list':
delete inputProps.items;
let listItems = input.items.map((item, index) => <ListItem key={"item-" + index}>{item}</ListItem>);

View File

@@ -4,12 +4,11 @@ import useAsyncSearch from "../hooks/async-search";
export default function SearchField(props) {
const { onSearch, displayText, onSelect, ...other } = props;
const { onSearch, onSelect, ...other } = props;
const [searchString, setSearchString, results] = useAsyncSearch(props.onSearch, 3);
return <Autocomplete {...other}
getOptionLabel={r => displayText(r)}
options={Object.values(results ?? {})}
onChange={(e, n) => onSelect(n)}
renderInput={(params) => (