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