diff options
author | Sebastian <sebasjm@gmail.com> | 2022-01-24 16:47:37 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-01-24 16:52:41 -0300 |
commit | 1374b37d2650ab428c9c2b07422afd6083697dfd (patch) | |
tree | b20eb62a725e3664783e5371cbf63f3a3dd420a5 /packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx | |
parent | 171d070a83c93082026c9e757f7520139ec655c9 (diff) | |
download | wallet-core-1374b37d2650ab428c9c2b07422afd6083697dfd.tar.xz |
some fixes: #7095 #7080 #7085 #7081 #7089 #7097
Diffstat (limited to 'packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx')
-rw-r--r-- | packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx index 61dad3f51..1fd4343ab 100644 --- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx +++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx @@ -12,7 +12,28 @@ import { SolveOverviewFeedbackDisplay } from "../SolveScreen"; import { AuthMethodSolveProps } from "./index"; export function AuthMethodSmsSolve({ id }: AuthMethodSolveProps): VNode { - const [answer, setAnswer] = useState("A-"); + const [answer, _setAnswer] = useState("A-"); + + function setAnswer(str: string): void { + //A-12345-678-1234-5678 + const unformatted = str + .replace(/^A-/, "") + .replace(/-/g, "") + .toLocaleUpperCase(); + + let result = `A-${unformatted.substring(0, 5)}`; + if (unformatted.length > 5) { + result += `-${unformatted.substring(5, 8)}`; + } + if (unformatted.length > 8) { + result += `-${unformatted.substring(8, 12)}`; + } + if (unformatted.length > 12) { + result += `-${unformatted.substring(12, 16)}`; + } + + _setAnswer(result); + } const [expanded, setExpanded] = useState(false); const reducer = useAnastasisContext(); @@ -77,7 +98,9 @@ export function AuthMethodSmsSolve({ id }: AuthMethodSolveProps): VNode { const feedback = challengeFeedback[selectedUuid]; async function onNext(): Promise<void> { - return reducer?.transition("solve_challenge", { answer }); + return reducer?.transition("solve_challenge", { + answer: `A-${answer.replace(/^A-/, "").replace(/-/g, "").trim()}`, + }); } function onCancel(): void { reducer?.back(); @@ -127,7 +150,7 @@ export function AuthMethodSmsSolve({ id }: AuthMethodSolveProps): VNode { grabFocus onConfirm={onNext} bind={[answer, setAnswer]} - placeholder="A-1234567812345678" + placeholder="A-12345-678-1234-5678" /> <div |