mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 19:26:07 +00:00
Update redirect to org after SSO
This commit is contained in:
@@ -154,6 +154,7 @@ export const initializeSamlStrategy = async () => {
|
|||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
organizationName: organization?.name,
|
organizationName: organization?.name,
|
||||||
|
organizationId: organization?._id,
|
||||||
authMethod: req.ssoConfig.authProvider,
|
authMethod: req.ssoConfig.authProvider,
|
||||||
isUserCompleted,
|
isUserCompleted,
|
||||||
...(req.body.RelayState ? {
|
...(req.body.RelayState ? {
|
||||||
|
|||||||
@@ -2,9 +2,15 @@ import { NextRouter } from "next/router";
|
|||||||
|
|
||||||
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
|
||||||
|
|
||||||
export const navigateUserToOrg = async (router: NextRouter) => {
|
export const navigateUserToOrg = async (router: NextRouter, organizationId?: string) => {
|
||||||
const userOrgs = await fetchOrganizations();
|
const userOrgs = await fetchOrganizations();
|
||||||
|
|
||||||
|
if (organizationId) {
|
||||||
|
localStorage.setItem("orgData.id", organizationId);
|
||||||
|
router.push(`/org/${organizationId}/overview`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (userOrgs.length > 0) {
|
if (userOrgs.length > 0) {
|
||||||
// user is part of at least 1 org
|
// user is part of at least 1 org
|
||||||
const userOrg = userOrgs[0] && userOrgs[0]._id;
|
const userOrg = userOrgs[0] && userOrgs[0]._id;
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export const MFAStep = ({
|
|||||||
let isLinkingRequired: undefined | boolean;
|
let isLinkingRequired: undefined | boolean;
|
||||||
let callbackPort: undefined | string;
|
let callbackPort: undefined | string;
|
||||||
let authMethod: undefined | AuthMethod;
|
let authMethod: undefined | AuthMethod;
|
||||||
|
let organizationId: undefined | string;
|
||||||
|
|
||||||
if (providerAuthToken) {
|
if (providerAuthToken) {
|
||||||
const decodedToken = jwt_decode(providerAuthToken) as any;
|
const decodedToken = jwt_decode(providerAuthToken) as any;
|
||||||
@@ -85,6 +86,7 @@ export const MFAStep = ({
|
|||||||
isLinkingRequired = decodedToken.isLinkingRequired;
|
isLinkingRequired = decodedToken.isLinkingRequired;
|
||||||
callbackPort = decodedToken.callbackPort;
|
callbackPort = decodedToken.callbackPort;
|
||||||
authMethod = decodedToken.authMethod;
|
authMethod = decodedToken.authMethod;
|
||||||
|
organizationId = decodedToken?.organizationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mfaCode.length !== 6) {
|
if (mfaCode.length !== 6) {
|
||||||
@@ -142,7 +144,7 @@ export const MFAStep = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await navigateUserToOrg(router);
|
await navigateUserToOrg(router, organizationId);
|
||||||
} else {
|
} else {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to log in",
|
text: "Failed to log in",
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ export const PasswordStep = ({
|
|||||||
const {
|
const {
|
||||||
callbackPort,
|
callbackPort,
|
||||||
isLinkingRequired,
|
isLinkingRequired,
|
||||||
authMethod
|
authMethod,
|
||||||
|
organizationId
|
||||||
} = jwt_decode(providerAuthToken) as any;
|
} = jwt_decode(providerAuthToken) as any;
|
||||||
|
|
||||||
const handleLogin = async (e:React.FormEvent) => {
|
const handleLogin = async (e:React.FormEvent) => {
|
||||||
@@ -107,7 +108,7 @@ export const PasswordStep = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await navigateUserToOrg(router);
|
await navigateUserToOrg(router, organizationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const SignupSSO = ({
|
|||||||
email,
|
email,
|
||||||
organizationName,
|
organizationName,
|
||||||
firstName,
|
firstName,
|
||||||
lastName
|
lastName,
|
||||||
} = jwt_decode(providerAuthToken) as any;
|
} = jwt_decode(providerAuthToken) as any;
|
||||||
|
|
||||||
const renderView = () => {
|
const renderView = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user