From fefdb0d7adcfe95be20f4ff81af316a0ca64f35a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 3 Nov 2021 18:52:10 +0100 Subject: [PATCH] anastasis-webui: display some crude challenge feedback --- .../pages/home/ChallengeOverviewScreen.tsx | 38 ++++++++++++++++--- 1 file 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 ( +
+

{feedback.message}

+
+ ); + case ChallengeFeedbackStatus.Pending: + case ChallengeFeedbackStatus.AuthIban: + return null; + case ChallengeFeedbackStatus.RateLimitExceeded: + return
Rate limit exceeded.
; + case ChallengeFeedbackStatus.Redirect: + return
Redirect (FIXME: not supported)
; + case ChallengeFeedbackStatus.Unsupported: + return
Challenge not supported by client.
; + case ChallengeFeedbackStatus.TruthUnknown: + return
Truth unknown
; + default: + return ( +
+
{JSON.stringify(feedback)}
+
+ ); + } +} + export function ChallengeOverviewScreen(): VNode { const reducer = useAnastasisContext(); @@ -98,11 +130,7 @@ export function ChallengeOverviewScreen(): VNode { {method?.icon} {info.instructions} - {info.feedback?.state === ChallengeFeedbackStatus.Message ? ( -
-

{info.feedback.message}

-
- ) : null} +
{method && info.feedback?.state !== "solved" ? (