Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"use server";
import { isRemoteDevelopmentEnvironmentEnabled } from "@/lib/remote-development-environment/env";

async function getStackServerApp() {
async function getServerApp() {
if (isRemoteDevelopmentEnvironmentEnabled()) {
throw new Error("Team invitation management is not available in the remote development environment dashboard.");
}
return (await import("@/stack/server")).stackServerApp;
return (await import("@/stack/server")).getStackServerApp();
}

export async function revokeInvitation(teamId: string, invitationId: string) {
"use server";
const stackServerApp = await getStackServerApp();
const stackServerApp = await getServerApp();
const user = await stackServerApp.getUser();
const team = await user?.getTeam(teamId);
if (!team) {
Expand All @@ -24,7 +24,7 @@ export async function revokeInvitation(teamId: string, invitationId: string) {
}

export async function listInvitations(teamId: string) {
const stackServerApp = await getStackServerApp();
const stackServerApp = await getServerApp();
const user = await stackServerApp.getUser();
const team = await user?.getTeam(teamId);
if (!team) {
Expand All @@ -39,7 +39,7 @@ export async function listInvitations(teamId: string) {
}

export async function inviteUser(teamId: string, email: string, origin: string) {
const stackServerApp = await getStackServerApp();
const stackServerApp = await getServerApp();
const callbackUrl = new URL(stackServerApp.urls.teamInvitation, origin).toString();
const user = await stackServerApp.getUser();
const team = await user?.getTeam(teamId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stackServerApp } from "@/stack/server";
import { getStackServerApp } from "@/stack/server";
import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env";
import { getOrCreateFeaturebaseUser } from "@stackframe/stack-shared/dist/utils/featurebase";
import { urlString } from "@stackframe/stack-shared/dist/utils/urls";
Expand All @@ -21,7 +21,7 @@ export default async function FeaturebaseSSO({
return <div>Missing return_to parameter. Please go back and try again.</div>;
}

const user = await stackServerApp.getUser();
const user = await getStackServerApp().getUser();
if (!user) {
redirect(urlString`/handler/sign-in?after_auth_return_to=${urlString`/integrations/featurebase/sso?return_to=${returnTo}`}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stackServerApp } from "@/stack/server";
import { getStackServerApp } from "@/stack/server";
import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env";
import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
import { redirect } from "next/navigation";
Expand All @@ -18,7 +18,7 @@ export default async function IntegrationConfirmPage(props: {
const onContinue = async (options: { projectId: string, projectName?: string }) => {
"use server";

const user = await stackServerApp.getUser();
const user = await getStackServerApp().getUser();
if (!user) {
return { error: "unauthorized" };
}
Expand Down
8 changes: 5 additions & 3 deletions apps/dashboard/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import '../polyfills';
import './globals.css';
import { LayoutClient } from './layout-client';

const apiUrl = getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL');

export const metadata: Metadata = {
metadataBase: new URL(getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL') || ''),
...apiUrl ? { metadataBase: new URL(apiUrl) } : {},
title: {
default: 'Stack Auth Dashboard',
template: '%s | Stack Auth',
Expand All @@ -23,12 +25,12 @@ export const metadata: Metadata = {
openGraph: {
title: 'Stack Auth Dashboard',
description: 'Stack Auth is the open-source Auth0 alternative, and the fastest way to add authentication to your web app.',
images: [`${getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL')}/open-graph-image.png`]
...apiUrl ? { images: [`${apiUrl}/open-graph-image.png`] } : {},
},
twitter: {
title: 'Stack Auth Dashboard',
description: 'Stack Auth is the open-source Auth0 alternative, and the fastest way to add authentication to your web app.',
images: [`${getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL')}/open-graph-image.png`]
...apiUrl ? { images: [`${apiUrl}/open-graph-image.png`] } : {},
},
};

Expand Down
19 changes: 13 additions & 6 deletions apps/dashboard/src/stack/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ import { StackServerApp } from "@stackframe/stack";
import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
import { stackClientApp } from "./client";

if (isRemoteDevelopmentEnvironmentEnabled()) {
throw new StackAssertionError("stackServerApp is not available in the local remote development environment dashboard.");
}
type InternalServerApp = StackServerApp<true, "internal">;
let _stackServerApp: InternalServerApp | undefined;

export const stackServerApp = new StackServerApp({
inheritsFrom: stackClientApp,
});
export function getStackServerApp(): InternalServerApp {
if (!_stackServerApp) {
if (isRemoteDevelopmentEnvironmentEnabled()) {
throw new StackAssertionError("stackServerApp is not available in the local remote development environment dashboard.");
}
_stackServerApp = new StackServerApp({
inheritsFrom: stackClientApp,
});
}
return _stackServerApp;
}
2 changes: 1 addition & 1 deletion packages/stack-cli/src/commands/whoami.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function registerWhoamiCommand(program: Command) {
.description("Show the currently logged-in Stack Auth CLI user")
.action(async () => {
const flags = program.opts();
const auth = resolveSessionAuth(flags);
const auth = resolveSessionAuth();
const user = await getInternalUser(auth);
const teams = await user.listTeams();

Expand Down
Loading