commit 955b03a413d8c6fd0e8749b7ffe33a2e1d28a90b
parent 19767d7d2a97e15b61a9c87c2b30fec7a128fc94
Author: Sebastian <sebasjm@gmail.com>
Date: Mon, 6 Dec 2021 11:01:42 -0300
feat #7034
Diffstat:
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/packages/merchant-backoffice/src/components/exception/login.tsx b/packages/merchant-backoffice/src/components/exception/login.tsx
@@ -38,6 +38,10 @@ function getTokenValuePart(t?: string): string | undefined {
return match[1];
}
+function normalizeToken(r: string | undefined): string | undefined {
+ return r ? `secret-token:${encodeURIComponent(r)}` : undefined;
+}
+
export function LoginModal({ onConfirm, withMessage }: Props): VNode {
const { url: backendUrl, token: baseToken } = useBackendContext();
const { admin, token: instanceToken } = useInstanceContext();
@@ -79,10 +83,7 @@ export function LoginModal({ onConfirm, withMessage }: Props): VNode {
value={url}
onKeyPress={(e) =>
e.keyCode === 13
- ? onConfirm(
- url,
- token ? `secret-token:${token}` : undefined
- )
+ ? onConfirm(url, normalizeToken(token))
: null
}
onInput={(e): void => setURL(e?.currentTarget.value)}
@@ -107,10 +108,7 @@ export function LoginModal({ onConfirm, withMessage }: Props): VNode {
name="token"
onKeyPress={(e) =>
e.keyCode === 13
- ? onConfirm(
- url,
- token ? `secret-token:${token}` : undefined
- )
+ ? onConfirm(url, normalizeToken(token))
: null
}
value={token}
@@ -132,7 +130,7 @@ export function LoginModal({ onConfirm, withMessage }: Props): VNode {
<button
class="button is-info"
onClick={(): void => {
- onConfirm(url, token ? `secret-token:${token}` : undefined);
+ onConfirm(url, normalizeToken(token));
}}
>
<Translate>Confirm</Translate>