fix redirect bug for some accounts when disable create org is enabled

This commit is contained in:
miloschwartz 2025-07-18 12:59:57 -07:00
parent 23eb0da7d7
commit b34c3db956
No known key found for this signature in database
5 changed files with 38 additions and 31 deletions

View file

@ -2,7 +2,7 @@ import path from "path";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
// This is a placeholder value replaced by the build process // This is a placeholder value replaced by the build process
export const APP_VERSION = "1.7.0"; export const APP_VERSION = "1.7.2";
export const __FILENAME = fileURLToPath(import.meta.url); export const __FILENAME = fileURLToPath(import.meta.url);
export const __DIRNAME = path.dirname(__FILENAME); export const __DIRNAME = path.dirname(__FILENAME);

View file

@ -162,6 +162,12 @@ export async function validateOidcCallback(
); );
} }
logger.debug("State verified", {
urL: ensureTrailingSlash(existingIdp.idpOidcConfig.tokenUrl),
expectedState,
state
});
const tokens = await client.validateAuthorizationCode( const tokens = await client.validateAuthorizationCode(
ensureTrailingSlash(existingIdp.idpOidcConfig.tokenUrl), ensureTrailingSlash(existingIdp.idpOidcConfig.tokenUrl),
code, code,

View file

@ -12,6 +12,7 @@ import { cleanRedirect } from "@app/lib/cleanRedirect";
import { Layout } from "@app/components/Layout"; import { Layout } from "@app/components/Layout";
import { InitialSetupCompleteResponse } from "@server/routers/auth"; import { InitialSetupCompleteResponse } from "@server/routers/auth";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
import { build } from "@server/build";
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
@ -83,25 +84,27 @@ export default async function Page(props: {
if (ownedOrg) { if (ownedOrg) {
redirect(`/${ownedOrg.orgId}`); redirect(`/${ownedOrg.orgId}`);
} else { } else {
if (!env.flags.disableUserCreateOrg || user.serverAdmin) {
redirect("/setup"); redirect("/setup");
} }
} }
}
// return ( return (
// <UserProvider user={user}> <UserProvider user={user}>
// <Layout orgs={orgs} navItems={[]}> <Layout orgs={orgs} navItems={[]}>
// <div className="w-full max-w-md mx-auto md:mt-32 mt-4"> <div className="w-full max-w-md mx-auto md:mt-32 mt-4">
// <OrganizationLanding <OrganizationLanding
// disableCreateOrg={ disableCreateOrg={
// env.flags.disableUserCreateOrg && !user.serverAdmin env.flags.disableUserCreateOrg && !user.serverAdmin
// } }
// organizations={orgs.map((org) => ({ organizations={orgs.map((org) => ({
// name: org.name, name: org.name,
// id: org.orgId id: org.orgId
// }))} }))}
// /> />
// </div> </div>
// </Layout> </Layout>
// </UserProvider> </UserProvider>
// ); );
} }

View file

@ -41,35 +41,31 @@ export default function OrganizationLanding({
function getDescriptionText() { function getDescriptionText() {
if (organizations.length === 0) { if (organizations.length === 0) {
if (!disableCreateOrg) { if (!disableCreateOrg) {
return t('componentsErrorNoMemberCreate'); return t("componentsErrorNoMemberCreate");
} else { } else {
return t('componentsErrorNoMember'); return t("componentsErrorNoMember");
} }
} }
return t('componentsMember', {count: organizations.length}); return t("componentsMember", { count: organizations.length });
} }
return ( return (
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>{t('welcome')}</CardTitle> <CardTitle>{t("welcome")}</CardTitle>
<CardDescription>{getDescriptionText()}</CardDescription> <CardDescription>{getDescriptionText()}</CardDescription>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
{organizations.length === 0 ? ( {organizations.length === 0 ? (
disableCreateOrg ? ( !disableCreateOrg && (
<p className="text-center text-muted-foreground">
t('componentsErrorNoMember')
</p>
) : (
<Link href="/setup"> <Link href="/setup">
<Button <Button
className="w-full h-auto py-3 text-lg" className="w-full h-auto py-3 text-lg"
size="lg" size="lg"
> >
<Plus className="mr-2 h-5 w-5" /> <Plus className="mr-2 h-5 w-5" />
{t('componentsCreateOrg')} {t("componentsCreateOrg")}
</Button> </Button>
</Link> </Link>
) )

View file

@ -103,8 +103,10 @@ export default function SecurityKeyForm({
}); });
useEffect(() => { useEffect(() => {
if (open) {
loadSecurityKeys(); loadSecurityKeys();
}, []); }
}, [open]);
const registerSchema = z.object({ const registerSchema = z.object({
name: z.string().min(1, { message: t("securityKeyNameRequired") }), name: z.string().min(1, { message: t("securityKeyNameRequired") }),