]> Untitled Git - lemmy-ui.git/commitdiff
Prevent JWT token from showing up on error page
authorSleeplessOne1917 <abias1122@gmail.com>
Sun, 2 Jul 2023 19:45:45 +0000 (15:45 -0400)
committerSleeplessOne1917 <abias1122@gmail.com>
Sun, 2 Jul 2023 19:45:45 +0000 (15:45 -0400)
src/shared/components/app/error-page.tsx
src/shared/utils/helpers/remove-auth-param.ts [new file with mode: 0644]

index ec352d4288dfeefbe628169b379e0b422575ec7a..996fcdb5fc814df52fd235e1a8a99238901381e8 100644 (file)
@@ -1,4 +1,5 @@
 import { setIsoData } from "@utils/app";
+import removeAuthParam from "@utils/helpers/remove-auth-param";
 import { Component } from "inferno";
 import { T } from "inferno-i18next-dess";
 import { Link } from "inferno-router";
@@ -58,7 +59,7 @@ export class ErrorPage extends Component<any, any> {
           <T
             i18nKey="error_code_message"
             parent="p"
-            interpolation={{ error: errorPageData.error }}
+            interpolation={{ error: removeAuthParam(errorPageData.error) }}
           >
             #<strong className="text-danger">#</strong>#
           </T>
diff --git a/src/shared/utils/helpers/remove-auth-param.ts b/src/shared/utils/helpers/remove-auth-param.ts
new file mode 100644 (file)
index 0000000..0702b10
--- /dev/null
@@ -0,0 +1,6 @@
+export default function (err: any) {
+  return err
+    .toString()
+    .replace(new RegExp("[?&]auth=[^&#]*(#.*)?$"), "$1")
+    .replace(new RegExp("([?&])auth=[^&]*&"), "$1");
+}