Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/web/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
NEXT_PUBLIC_BACKEND_URL=https://api.supermemory.ai
NEXT_PUBLIC_POSTHOG_KEY=
EXA_API_KEY=
XAI_API_KEY=
XAI_API_KEY=

# Social sign-in providers. Both are shown by default; set a flag to "false" to
# hide that provider's button on self-hosted deployments.
NEXT_PUBLIC_GOOGLE_AUTH_ENABLED=
NEXT_PUBLIC_GITHUB_AUTH_ENABLED=
25 changes: 21 additions & 4 deletions apps/web/app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ import {
shouldUseReviewerPasswordLogin,
} from "@/lib/reviewer-password-login"

/**
* `NEXT_PUBLIC_<PROVIDER>_AUTH_ENABLED` is an opt-out switch, not an opt-in one:
* self-hosted deployments show every social provider by default, and an operator
* turns one off by setting the flag to a falsy value. Treating any other value as
* "enabled" keeps `..._AUTH_ENABLED=true` from hiding the provider it names.
*/
function isSocialProviderEnabled(flag: string | undefined): boolean {
if (flag === undefined || flag === "") return true
return flag !== "false" && flag !== "0"
}

const isGoogleAuthEnabled =
process.env.NEXT_PUBLIC_HOST_ID === "supermemory" ||
isSocialProviderEnabled(process.env.NEXT_PUBLIC_GOOGLE_AUTH_ENABLED)

const isGithubAuthEnabled =
process.env.NEXT_PUBLIC_HOST_ID === "supermemory" ||
isSocialProviderEnabled(process.env.NEXT_PUBLIC_GITHUB_AUTH_ENABLED)

function isMcpOAuthAuthorizeContext(sp: Pick<URLSearchParams, "get">): boolean {
return sp.get("response_type") === "code" && Boolean(sp.get("client_id"))
}
Expand Down Expand Up @@ -475,8 +494,7 @@ export default function LoginPage() {
)}

<div className="flex flex-col gap-3">
{process.env.NEXT_PUBLIC_HOST_ID === "supermemory" ||
!process.env.NEXT_PUBLIC_GOOGLE_AUTH_ENABLED ? (
{isGoogleAuthEnabled ? (
<div className="w-full">
<LastUsedBadge show={lastUsedMethod === "google"} />
<ExternalAuthButton
Expand Down Expand Up @@ -532,8 +550,7 @@ export default function LoginPage() {
/>
</div>
) : null}
{process.env.NEXT_PUBLIC_HOST_ID === "supermemory" ||
!process.env.NEXT_PUBLIC_GITHUB_AUTH_ENABLED ? (
{isGithubAuthEnabled ? (
<div className="w-full">
<LastUsedBadge show={lastUsedMethod === "github"} />
<ExternalAuthButton
Expand Down