Merge pull request #2969 from Infisical/misc/fix-shared-secret-within-org-and-login-redirect

misc: resolve shared secret within org and added login redirect
This commit is contained in:
Sheen
2025-01-11 02:16:48 +08:00
committed by GitHub
5 changed files with 79 additions and 7 deletions
+16
View File
@@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import SecurityClient from "@app/components/utilities/SecurityClient";
import { apiRequest } from "@app/config/request";
import { SessionStorageKeys } from "@app/const";
import { organizationKeys } from "../organization/queries";
import { setAuthToken } from "../reactQuery";
@@ -86,6 +87,21 @@ export const useSelectOrganization = () => {
SecurityClient.setProviderAuthToken("");
}
if (data.token && !data.isMfaEnabled) {
// We check if there is a pending callback after organization login success and redirect to it if valid
const loginRedirectInfo = sessionStorage.getItem(
SessionStorageKeys.ORG_LOGIN_SUCCESS_REDIRECT_URL
);
sessionStorage.removeItem(SessionStorageKeys.ORG_LOGIN_SUCCESS_REDIRECT_URL);
if (loginRedirectInfo) {
const { expiry, data: redirectUrl } = JSON.parse(loginRedirectInfo);
if (new Date() < new Date(expiry)) {
window.location.assign(redirectUrl);
}
}
}
return data;
},
onSuccess: () => {