diff options
author | Florian Dold <florian@dold.me> | 2021-11-03 18:52:10 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-11-03 18:52:10 +0100 |
commit | fefdb0d7adcfe95be20f4ff81af316a0ca64f35a (patch) | |
tree | 9667e4cd85bdfa960ff63b03c79315f3670ddaf4 /packages | |
parent | 7d24d2254b49010eb0e6e6af54a0f381cfdc4b53 (diff) |
anastasis-webui: display some crude challenge feedback
Diffstat (limited to 'packages')
-rw-r--r-- | packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx index c63f19eb6..69dbce037 100644 --- a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx +++ b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx @@ -5,6 +5,38 @@ import { useAnastasisContext } from "../../context/anastasis"; import { AnastasisClientFrame } from "./index"; import { authMethods, KnownAuthMethods } from "./authMethod"; +function FeedbackDisplay(props: { feedback?: ChallengeFeedback }) { + const { feedback } = props; + if (!feedback) { + return null; + } + switch (feedback.state) { + case ChallengeFeedbackStatus.Message: + return ( + <div> + <p>{feedback.message}</p> + </div> + ); + case ChallengeFeedbackStatus.Pending: + case ChallengeFeedbackStatus.AuthIban: + return null; + case ChallengeFeedbackStatus.RateLimitExceeded: + return <div>Rate limit exceeded.</div>; + case ChallengeFeedbackStatus.Redirect: + return <div>Redirect (FIXME: not supported)</div>; + case ChallengeFeedbackStatus.Unsupported: + return <div>Challenge not supported by client.</div>; + case ChallengeFeedbackStatus.TruthUnknown: + return <div>Truth unknown</div>; + default: + return ( + <div> + <pre>{JSON.stringify(feedback)}</pre> + </div> + ); + } +} + export function ChallengeOverviewScreen(): VNode { const reducer = useAnastasisContext(); @@ -98,11 +130,7 @@ export function ChallengeOverviewScreen(): VNode { <span class="icon">{method?.icon}</span> <span>{info.instructions}</span> </div> - {info.feedback?.state === ChallengeFeedbackStatus.Message ? ( - <div> - <p>{info.feedback.message}</p> - </div> - ) : null} + <FeedbackDisplay feedback={info.feedback} /> </div> <div> {method && info.feedback?.state !== "solved" ? ( |