From 603ace074078d3f9fd8a04f41c8e32f12fe02b20 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Wed, 13 Dec 2023 09:53:29 -0800 Subject: [PATCH] Fix redirect to login page (#1445) Fixes https://github.com/webrecorder/browsertrix-cloud/issues/1436, regression introduced in https://github.com/webrecorder/browsertrix-cloud/pull/1381 --- frontend/src/features/accounts/account-settings.ts | 2 +- frontend/src/pages/crawls.ts | 2 +- frontend/src/pages/org/index.ts | 2 +- frontend/src/pages/orgs.ts | 2 +- frontend/src/pages/users-invite.ts | 2 +- frontend/src/utils/auth.ts | 7 +++++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/features/accounts/account-settings.ts b/frontend/src/features/accounts/account-settings.ts index c67403f6..600bc084 100644 --- a/frontend/src/features/accounts/account-settings.ts +++ b/frontend/src/features/accounts/account-settings.ts @@ -88,9 +88,9 @@ export class RequestVerify extends LitElement { } } -@needLogin @localized() @customElement("btrix-account-settings") +@needLogin export class AccountSettings extends LiteElement { @property({ type: Object }) authState?: AuthState; diff --git a/frontend/src/pages/crawls.ts b/frontend/src/pages/crawls.ts index 1d3a7937..cc3815c6 100644 --- a/frontend/src/pages/crawls.ts +++ b/frontend/src/pages/crawls.ts @@ -36,9 +36,9 @@ const sortableFields: Record< }; const ABORT_REASON_THROTTLE = "throttled"; -@needLogin @localized() @customElement("btrix-crawls") +@needLogin export class Crawls extends LiteElement { @property({ type: Object }) authState!: AuthState; diff --git a/frontend/src/pages/org/index.ts b/frontend/src/pages/org/index.ts index 60450a68..9ff59a73 100644 --- a/frontend/src/pages/org/index.ts +++ b/frontend/src/pages/org/index.ts @@ -78,9 +78,9 @@ const defaultTab = "home"; const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/; -@needLogin @localized() @customElement("btrix-org") +@needLogin export class Org extends LiteElement { @property({ type: Object }) authState?: AuthState; diff --git a/frontend/src/pages/orgs.ts b/frontend/src/pages/orgs.ts index 55cf876f..e50cbe0c 100644 --- a/frontend/src/pages/orgs.ts +++ b/frontend/src/pages/orgs.ts @@ -8,9 +8,9 @@ import LiteElement, { html } from "@/utils/LiteElement"; import { needLogin } from "@/utils/auth"; import type { APIPaginatedList } from "@/types/api"; -@needLogin @localized() @customElement("btrix-orgs") +@needLogin export class Orgs extends LiteElement { @property({ type: Object }) authState?: AuthState; diff --git a/frontend/src/pages/users-invite.ts b/frontend/src/pages/users-invite.ts index f0850756..82443b25 100644 --- a/frontend/src/pages/users-invite.ts +++ b/frontend/src/pages/users-invite.ts @@ -6,9 +6,9 @@ import LiteElement, { html } from "@/utils/LiteElement"; import { needLogin } from "@/utils/auth"; import type { CurrentUser } from "@/types/user"; -@needLogin @localized() @customElement("btrix-users-invite") +@needLogin export class UsersInvite extends LiteElement { @property({ type: Object }) authState?: AuthState; diff --git a/frontend/src/utils/auth.ts b/frontend/src/utils/auth.ts index 89500340..7b44c2ec 100644 --- a/frontend/src/utils/auth.ts +++ b/frontend/src/utils/auth.ts @@ -3,10 +3,13 @@ import type { AuthState } from "@/utils/AuthService"; import AuthService from "@/utils/AuthService"; /** - * Block rendering and dispatch event if user is not logged in + * Block rendering and dispatch event if user is not logged in. + * When using with other class decorators, `@needLogin` should + * be closest to the component (see usage example.) * - * Usage example: + * @example Usage: * ```ts + * @customElement("my-component") * @needLogin * MyComponent extends LiteElement {} * ```