Merge pull request #1766 from LemmyNet/auth-error-message

Prevent JWT token from showing up on error page
This commit is contained in:
SleeplessOne1917 2023-07-02 22:37:37 +00:00 committed by GitHub
commit ce1f979c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 1253 additions and 940 deletions

View file

@ -1,4 +1,5 @@
import { setIsoData } from "@utils/app"; import { setIsoData } from "@utils/app";
import { removeAuthParam } from "@utils/helpers";
import { Component } from "inferno"; import { Component } from "inferno";
import { T } from "inferno-i18next-dess"; import { T } from "inferno-i18next-dess";
import { Link } from "inferno-router"; import { Link } from "inferno-router";
@ -58,7 +59,7 @@ export class ErrorPage extends Component<any, any> {
<T <T
i18nKey="error_code_message" i18nKey="error_code_message"
parent="p" parent="p"
interpolation={{ error: errorPageData.error }} interpolation={{ error: removeAuthParam(errorPageData.error) }}
> >
#<strong className="text-danger">#</strong># #<strong className="text-danger">#</strong>#
</T> </T>

View file

@ -17,6 +17,7 @@ import isCakeDay from "./is-cake-day";
import numToSI from "./num-to-si"; import numToSI from "./num-to-si";
import poll from "./poll"; import poll from "./poll";
import randomStr from "./random-str"; import randomStr from "./random-str";
import removeAuthParam from "./remove-auth-param";
import sleep from "./sleep"; import sleep from "./sleep";
import validEmail from "./valid-email"; import validEmail from "./valid-email";
import validInstanceTLD from "./valid-instance-tld"; import validInstanceTLD from "./valid-instance-tld";
@ -43,6 +44,7 @@ export {
numToSI, numToSI,
poll, poll,
randomStr, randomStr,
removeAuthParam,
sleep, sleep,
validEmail, validEmail,
validInstanceTLD, validInstanceTLD,

View file

@ -0,0 +1,6 @@
export default function (err: any) {
return err
.toString()
.replace(new RegExp("[?&]auth=[^&#]*(#.*)?$"), "$1")
.replace(new RegExp("([?&])auth=[^&]*&"), "$1");
}

2182
yarn.lock

File diff suppressed because it is too large Load diff