Select organization checkpoint

This commit is contained in:
x032205
2025-06-04 16:54:14 -04:00
parent 92b9abb52b
commit 952e60f08a
3 changed files with 8 additions and 4 deletions
@@ -7,7 +7,8 @@ import { SelectOrganizationPage } from "./SelectOrgPage";
export const SelectOrganizationPageQueryParams = z.object({ export const SelectOrganizationPageQueryParams = z.object({
org_id: z.string().optional().catch(""), org_id: z.string().optional().catch(""),
callback_port: z.coerce.number().optional().catch(undefined), callback_port: z.coerce.number().optional().catch(undefined),
is_admin_login: z.boolean().optional().catch(false) is_admin_login: z.boolean().optional().catch(false),
force: z.boolean().optional()
}); });
export const Route = createFileRoute("/_restrict-login-signup/login/select-organization")({ export const Route = createFileRoute("/_restrict-login-signup/login/select-organization")({
@@ -243,7 +243,7 @@ export const SignupInvitePage = () => {
SecurityClient.setSignupToken(response.token); SecurityClient.setSignupToken(response.token);
setStep(2); setStep(2);
} else { } else {
navigate({ to: "/login" }); navigate({ to: "/login/select-organization", search: { force: true } });
// TODO: Redirect user to the newly joined org. The commented code does not work due to auth issues. // TODO: Redirect user to the newly joined org. The commented code does not work due to auth issues.
// const redirectExistingUser = async () => { // const redirectExistingUser = async () => {
@@ -15,7 +15,8 @@ import { setAuthToken } from "@app/hooks/api/reactQuery";
import { ProjectType } from "@app/hooks/api/workspace/types"; import { ProjectType } from "@app/hooks/api/workspace/types";
const QueryParamsSchema = z.object({ const QueryParamsSchema = z.object({
callback_port: z.coerce.number().optional().catch(undefined) callback_port: z.coerce.number().optional().catch(undefined),
force: z.boolean().optional()
}); });
export const AuthConsentWrapper = () => { export const AuthConsentWrapper = () => {
@@ -71,7 +72,7 @@ export const AuthConsentWrapper = () => {
export const Route = createFileRoute("/_restrict-login-signup")({ export const Route = createFileRoute("/_restrict-login-signup")({
validateSearch: zodValidator(QueryParamsSchema), validateSearch: zodValidator(QueryParamsSchema),
search: { search: {
middlewares: [stripSearchParams({ callback_port: undefined })] middlewares: [stripSearchParams({ callback_port: undefined, force: undefined })]
}, },
beforeLoad: async ({ context, location, search }) => { beforeLoad: async ({ context, location, search }) => {
if (location.pathname === "/signupinvite") return; if (location.pathname === "/signupinvite") return;
@@ -93,6 +94,8 @@ export const Route = createFileRoute("/_restrict-login-signup")({
setAuthToken(data.token); setAuthToken(data.token);
if (location.pathname.endsWith("select-organization") && search?.force === true) return;
// to do cli login // to do cli login
if (search?.callback_port) { if (search?.callback_port) {
if (location.pathname.endsWith("select-organization") || location.pathname.endsWith("login")) if (location.pathname.endsWith("select-organization") || location.pathname.endsWith("login"))