fix: layout token redirect

This commit is contained in:
Piyush Gupta
2025-11-24 20:12:34 +05:30
parent 219983d8ed
commit ad08ed8471
4 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -81,7 +81,8 @@ export const registerAuthRoutes = async (server: FastifyZodProvider) => {
response: { response: {
200: z.object({ 200: z.object({
token: z.string(), token: z.string(),
organizationId: z.string().optional() organizationId: z.string().optional(),
subOrganizationId: z.string().optional()
}) })
} }
}, },
@@ -131,7 +132,6 @@ export const registerAuthRoutes = async (server: FastifyZodProvider) => {
appCfg.AUTH_SECRET, appCfg.AUTH_SECRET,
{ expiresIn } { expiresIn }
); );
return { token, organizationId: decodedToken.organizationId, subOrganizationId: decodedToken.subOrganizationId }; return { token, organizationId: decodedToken.organizationId, subOrganizationId: decodedToken.subOrganizationId };
} }
}); });
+1
View File
@@ -1,6 +1,7 @@
export type GetAuthTokenAPI = { export type GetAuthTokenAPI = {
token: string; token: string;
organizationId?: string; organizationId?: string;
subOrganizationId?: string;
}; };
export enum UserEncryptionVersion { export enum UserEncryptionVersion {
@@ -250,6 +250,8 @@ export const Navbar = () => {
subOrganizationId: subOrgId subOrganizationId: subOrgId
}); });
localStorage.setItem("orgData.id", subOrgId);
if (isMfaEnabled) { if (isMfaEnabled) {
SecurityClient.setMfaToken(token); SecurityClient.setMfaToken(token);
if (mfaMethod) { if (mfaMethod) {
@@ -117,9 +117,10 @@ export const Route = createFileRoute("/_restrict-login-signup")({
return; return;
throw redirect({ to: "/login/select-organization" }); throw redirect({ to: "/login/select-organization" });
} }
const orgId = data.subOrganizationId || data.organizationId;
throw redirect({ throw redirect({
to: "/organizations/$orgId/projects", to: "/organizations/$orgId/projects",
params: { orgId: data.organizationId } params: { orgId }
}); });
}, },
component: AuthConsentWrapper component: AuthConsentWrapper