mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 22:27:22 +00:00
Fixed the bug with creating projects
This commit is contained in:
@@ -19,7 +19,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|||||||
import getOrganizations from "~/pages/api/organization/getOrgs";
|
import getOrganizations from "~/pages/api/organization/getOrgs";
|
||||||
import getOrganizationUserProjects from "~/pages/api/organization/GetOrgUserProjects";
|
import getOrganizationUserProjects from "~/pages/api/organization/GetOrgUserProjects";
|
||||||
import getOrganizationUsers from "~/pages/api/organization/GetOrgUsers";
|
import getOrganizationUsers from "~/pages/api/organization/GetOrgUsers";
|
||||||
import checkUserAction from "~/pages/api/userActions/checkUserAction";
|
import getUser from "~/pages/api/user/getUser";
|
||||||
import addUserToWorkspace from "~/pages/api/workspace/addUserToWorkspace";
|
import addUserToWorkspace from "~/pages/api/workspace/addUserToWorkspace";
|
||||||
import createWorkspace from "~/pages/api/workspace/createWorkspace";
|
import createWorkspace from "~/pages/api/workspace/createWorkspace";
|
||||||
import getWorkspaces from "~/pages/api/workspace/getWorkspaces";
|
import getWorkspaces from "~/pages/api/workspace/getWorkspaces";
|
||||||
@@ -39,6 +39,7 @@ import Listbox from "./Listbox";
|
|||||||
interface LayoutProps {
|
interface LayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
const crypto = require("crypto");
|
||||||
|
|
||||||
export default function Layout({ children }: LayoutProps) {
|
export default function Layout({ children }: LayoutProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -83,12 +84,31 @@ export default function Layout({ children }: LayoutProps) {
|
|||||||
});
|
});
|
||||||
const newWorkspaceId = newWorkspace._id;
|
const newWorkspaceId = newWorkspace._id;
|
||||||
|
|
||||||
|
const randomBytes = crypto.randomBytes(16).toString("hex");
|
||||||
|
const PRIVATE_KEY = String(localStorage.getItem("PRIVATE_KEY"));
|
||||||
|
|
||||||
|
const myUser = await getUser();
|
||||||
|
|
||||||
|
const { ciphertext, nonce } = encryptAssymmetric({
|
||||||
|
plaintext: randomBytes,
|
||||||
|
publicKey: myUser.publicKey,
|
||||||
|
privateKey: PRIVATE_KEY,
|
||||||
|
}) as { ciphertext: string; nonce: string };
|
||||||
|
|
||||||
|
await uploadKeys(
|
||||||
|
newWorkspaceId,
|
||||||
|
myUser._id,
|
||||||
|
ciphertext,
|
||||||
|
nonce
|
||||||
|
);
|
||||||
|
|
||||||
if (addAllUsers) {
|
if (addAllUsers) {
|
||||||
|
console.log('adding other users')
|
||||||
const orgUsers = await getOrganizationUsers({
|
const orgUsers = await getOrganizationUsers({
|
||||||
orgId: tempLocalStorage("orgData.id"),
|
orgId: tempLocalStorage("orgData.id"),
|
||||||
});
|
});
|
||||||
orgUsers.map(async (user: any) => {
|
orgUsers.map(async (user: any) => {
|
||||||
if (user.status == "accepted") {
|
if (user.status == "accepted" && user.email != myUser.email) {
|
||||||
const result = await addUserToWorkspace(
|
const result = await addUserToWorkspace(
|
||||||
user.user.email,
|
user.user.email,
|
||||||
newWorkspaceId
|
newWorkspaceId
|
||||||
|
|||||||
Reference in New Issue
Block a user