mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-30 17:11:43 +00:00
Extract helper function
This commit is contained in:
parent
f31cd42d8e
commit
ab3fed3ddf
|
@ -5,7 +5,7 @@ import { LoginResponse, MyUserInfo } from "lemmy-js-client";
|
||||||
import { BehaviorSubject } from "rxjs";
|
import { BehaviorSubject } from "rxjs";
|
||||||
import { isHttps } from "../env";
|
import { isHttps } from "../env";
|
||||||
import { i18n } from "../i18next";
|
import { i18n } from "../i18next";
|
||||||
import { isBrowser, toast } from "../utils";
|
import { isAuthPath, isBrowser, toast } from "../utils";
|
||||||
|
|
||||||
interface Claims {
|
interface Claims {
|
||||||
sub: number;
|
sub: number;
|
||||||
|
@ -48,11 +48,7 @@ export class UserService {
|
||||||
this.myUserInfo = undefined;
|
this.myUserInfo = undefined;
|
||||||
IsomorphicCookie.remove("jwt"); // TODO is sometimes unreliable for some reason
|
IsomorphicCookie.remove("jwt"); // TODO is sometimes unreliable for some reason
|
||||||
document.cookie = "jwt=; Max-Age=0; path=/; domain=" + location.hostname;
|
document.cookie = "jwt=; Max-Age=0; path=/; domain=" + location.hostname;
|
||||||
if (
|
if (isAuthPath(location.pathname)) {
|
||||||
/create_.*|inbox|settings|setup|admin|reports|registration_applications/g.test(
|
|
||||||
location.pathname
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
location.replace("/");
|
location.replace("/");
|
||||||
} else {
|
} else {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|
|
@ -1603,3 +1603,9 @@ export function getQueryString<T extends Record<string, string | undefined>>(
|
||||||
"?"
|
"?"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isAuthPath(pathname: string) {
|
||||||
|
return /create_.*|inbox|settings|setup|admin|reports|registration_applications/g.test(
|
||||||
|
pathname
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue