mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 10:05:53 +02:00
fix redirect bug for some accounts when disable create org is enabled
This commit is contained in:
parent
23eb0da7d7
commit
b34c3db956
5 changed files with 38 additions and 31 deletions
|
@ -2,7 +2,7 @@ import path from "path";
|
|||
import { fileURLToPath } from "url";
|
||||
|
||||
// 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 __DIRNAME = path.dirname(__FILENAME);
|
||||
|
|
|
@ -162,6 +162,12 @@ export async function validateOidcCallback(
|
|||
);
|
||||
}
|
||||
|
||||
logger.debug("State verified", {
|
||||
urL: ensureTrailingSlash(existingIdp.idpOidcConfig.tokenUrl),
|
||||
expectedState,
|
||||
state
|
||||
});
|
||||
|
||||
const tokens = await client.validateAuthorizationCode(
|
||||
ensureTrailingSlash(existingIdp.idpOidcConfig.tokenUrl),
|
||||
code,
|
||||
|
|
|
@ -12,6 +12,7 @@ import { cleanRedirect } from "@app/lib/cleanRedirect";
|
|||
import { Layout } from "@app/components/Layout";
|
||||
import { InitialSetupCompleteResponse } from "@server/routers/auth";
|
||||
import { cookies } from "next/headers";
|
||||
import { build } from "@server/build";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
@ -83,25 +84,27 @@ export default async function Page(props: {
|
|||
if (ownedOrg) {
|
||||
redirect(`/${ownedOrg.orgId}`);
|
||||
} else {
|
||||
redirect("/setup");
|
||||
if (!env.flags.disableUserCreateOrg || user.serverAdmin) {
|
||||
redirect("/setup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return (
|
||||
// <UserProvider user={user}>
|
||||
// <Layout orgs={orgs} navItems={[]}>
|
||||
// <div className="w-full max-w-md mx-auto md:mt-32 mt-4">
|
||||
// <OrganizationLanding
|
||||
// disableCreateOrg={
|
||||
// env.flags.disableUserCreateOrg && !user.serverAdmin
|
||||
// }
|
||||
// organizations={orgs.map((org) => ({
|
||||
// name: org.name,
|
||||
// id: org.orgId
|
||||
// }))}
|
||||
// />
|
||||
// </div>
|
||||
// </Layout>
|
||||
// </UserProvider>
|
||||
// );
|
||||
return (
|
||||
<UserProvider user={user}>
|
||||
<Layout orgs={orgs} navItems={[]}>
|
||||
<div className="w-full max-w-md mx-auto md:mt-32 mt-4">
|
||||
<OrganizationLanding
|
||||
disableCreateOrg={
|
||||
env.flags.disableUserCreateOrg && !user.serverAdmin
|
||||
}
|
||||
organizations={orgs.map((org) => ({
|
||||
name: org.name,
|
||||
id: org.orgId
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</Layout>
|
||||
</UserProvider>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -41,35 +41,31 @@ export default function OrganizationLanding({
|
|||
function getDescriptionText() {
|
||||
if (organizations.length === 0) {
|
||||
if (!disableCreateOrg) {
|
||||
return t('componentsErrorNoMemberCreate');
|
||||
return t("componentsErrorNoMemberCreate");
|
||||
} else {
|
||||
return t('componentsErrorNoMember');
|
||||
return t("componentsErrorNoMember");
|
||||
}
|
||||
}
|
||||
|
||||
return t('componentsMember', {count: organizations.length});
|
||||
return t("componentsMember", { count: organizations.length });
|
||||
}
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t('welcome')}</CardTitle>
|
||||
<CardTitle>{t("welcome")}</CardTitle>
|
||||
<CardDescription>{getDescriptionText()}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{organizations.length === 0 ? (
|
||||
disableCreateOrg ? (
|
||||
<p className="text-center text-muted-foreground">
|
||||
t('componentsErrorNoMember')
|
||||
</p>
|
||||
) : (
|
||||
!disableCreateOrg && (
|
||||
<Link href="/setup">
|
||||
<Button
|
||||
className="w-full h-auto py-3 text-lg"
|
||||
size="lg"
|
||||
>
|
||||
<Plus className="mr-2 h-5 w-5" />
|
||||
{t('componentsCreateOrg')}
|
||||
{t("componentsCreateOrg")}
|
||||
</Button>
|
||||
</Link>
|
||||
)
|
||||
|
|
|
@ -103,8 +103,10 @@ export default function SecurityKeyForm({
|
|||
});
|
||||
|
||||
useEffect(() => {
|
||||
loadSecurityKeys();
|
||||
}, []);
|
||||
if (open) {
|
||||
loadSecurityKeys();
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
const registerSchema = z.object({
|
||||
name: z.string().min(1, { message: t("securityKeyNameRequired") }),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue