Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Patch organization invitation emails expiring for existing users and billing logic affected by missing organization populate call
Tuan Dangb9ae224aef4f
diff --git a/backend/src/controllers/v1/membershipOrgController.ts b/backend/src/controllers/v1/membershipOrgController.tsindex b25a9b9a78..18247f10f5 100644--- a/backend/src/controllers/v1/membershipOrgController.ts+++ b/backend/src/controllers/v1/membershipOrgController.ts@@ -1,3 +1,4 @@+import { Types } from 'mongoose';import { Request, Response } from 'express';import * as Sentry from '@sentry/node';import { MembershipOrg, Organization, User } from '../../models';@@ -139,7 +140,7 @@ export const inviteUserToOrganization = async (req: Request, res: Response) => {inviteEmail: inviteeEmail,organization: organizationId,role: MEMBER,- status: invitee?.publicKey ? ACCEPTED : INVITED+ status: INVITED}).save();}} else {@@ -164,6 +165,7 @@ export const inviteUserToOrganization = async (req: Request, res: Response) => {const organization = await Organization.findOne({ _id: organizationId });if (organization) {+const token = await TokenService.createToken({type: TOKEN_EMAIL_ORG_INVITATION,email: inviteeEmail,@@ -179,6 +181,7 @@ export const inviteUserToOrganization = async (req: Request, res: Response) => {inviterEmail: req.user.email,organizationName: organization.name,email: inviteeEmail,+ organizationId: organization._id.toString(),token,callback_url: (await getSiteURL()) + '/signupinvite'}@@ -214,13 +217,18 @@ export const inviteUserToOrganization = async (req: Request, res: Response) => {export const verifyUserToOrganization = async (req: Request, res: Response) => {let user, token;try {- const { email, code } = req.body;+ const {+ email,+ organizationId,+ code+ } = req.body;user = await User.findOne({ email }).select('+publicKey');const membershipOrg = await MembershipOrg.findOne({inviteEmail: email,- status: INVITED+ status: INVITED,+ organization: new Types.ObjectId(organizationId)});if (!membershipOrg)diff --git a/backend/src/controllers/v1/organizationController.ts b/backend/src/controllers/v1/organizationController.tsindex 6b082dac5a..17103a7a68 100644--- a/backend/src/controllers/v1/organizationController.ts+++ b/backend/src/controllers/v1/organizationController.ts@@ -85,7 +85,7 @@ export const createOrganization = async (req: Request, res: Response) => {export const getOrganization = async (req: Request, res: Response) => {let organization;try {- organization = req.membershipOrg.organization;+ organization = req.organization} catch (err) {Sentry.setUser({ email: req.user.email });Sentry.captureException(err);@@ -323,14 +323,14 @@ export const createOrganizationPortalSession = async (// check if there is a payment method on fileconst paymentMethods = await stripe.paymentMethods.list({- customer: req.membershipOrg.organization.customerId,+ customer: req.organization.customerId,type: 'card'});-+if (paymentMethods.data.length < 1) {// case: no payment method on filesession = await stripe.checkout.sessions.create({- customer: req.membershipOrg.organization.customerId,+ customer: req.organization.customerId,mode: 'setup',payment_method_types: ['card'],success_url: (await getSiteURL()) + '/dashboard',@@ -338,7 +338,7 @@ export const createOrganizationPortalSession = async (});} else {session = await stripe.billingPortal.sessions.create({- customer: req.membershipOrg.organization.customerId,+ customer: req.organization.customerId,return_url: (await getSiteURL()) + '/dashboard'});}@@ -370,7 +370,7 @@ export const getOrganizationSubscriptions = async (});subscriptions = await stripe.subscriptions.list({- customer: req.membershipOrg.organization.customerId+ customer: req.organization.customerId});} catch (err) {Sentry.setUser({ email: req.user.email });diff --git a/backend/src/routes/v1/inviteOrg.ts b/backend/src/routes/v1/inviteOrg.tsindex 4762711fe3..9b4889bc93 100644--- a/backend/src/routes/v1/inviteOrg.ts+++ b/backend/src/routes/v1/inviteOrg.ts@@ -19,6 +19,7 @@ router.post(router.post('/verify',body('email').exists().trim().notEmpty(),+ body('organizationId').exists().trim().notEmpty(),body('code').exists().trim().notEmpty(),validateRequest,membershipOrgController.verifyUserToOrganizationdiff --git a/backend/src/templates/organizationInvitation.handlebars b/backend/src/templates/organizationInvitation.handlebarsindex 045a9602b9..b281786f4e 100644--- a/backend/src/templates/organizationInvitation.handlebars+++ b/backend/src/templates/organizationInvitation.handlebars@@ -9,7 +9,7 @@<body><h2>Join your organization on Infisical</h2><p>{{inviterFirstName}} ({{inviterEmail}}) has invited you to their Infisical organization — {{organizationName}}</p>- <a href="{{callback_url}}?token={{token}}&to={{email}}">Join now</a>+ <a href="{{callback_url}}?token={{token}}&to={{email}}&organization_id={{organizationId}}">Join now</a><h3>What is Infisical?</h3><p>Infisical is an easy-to-use end-to-end encrypted tool that enables developers to sync and manage their secrets and configs.</p></body>diff --git a/frontend/src/pages/api/auth/VerifySignupInvite.ts b/frontend/src/pages/api/auth/VerifySignupInvite.tsindex 71f7246542..232e044f3a 100644--- a/frontend/src/pages/api/auth/VerifySignupInvite.ts+++ b/frontend/src/pages/api/auth/VerifySignupInvite.ts@@ -1,22 +1,25 @@interface Props {email: string;code: string;+ organizationId: string;}/*** This route verifies the signup invite link* @param {object} obj* @param {string} obj.email - email that a user is trying to verify+ * @param {string} obj.organizationId - id of organization that a user is trying to verify for* @param {string} obj.code - code that a user received to the abovementioned email* @returns*/-const verifySignupInvite = ({ email, code }: Props) => fetch('/api/v1/invite-org/verify', {+const verifySignupInvite = ({ email, organizationId, code }: Props) => fetch('/api/v1/invite-org/verify', {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({email,+ organizationId,code})});diff --git a/frontend/src/pages/signupinvite.tsx b/frontend/src/pages/signupinvite.tsxindex abe5d37709..4aa9a0c774 100644--- a/frontend/src/pages/signupinvite.tsx+++ b/frontend/src/pages/signupinvite.tsx@@ -51,6 +51,7 @@ export default function SignupInvite() {const router = useRouter();const parsedUrl = queryString.parse(router.asPath.split('?')[1]);const token = parsedUrl.token as string;+ const organizationId = parsedUrl.organization_id as string;const email = (parsedUrl.to as string)?.replace(' ', '+').trim();// Verifies if the information that the users entered (name, workspace) is there, and if the password matched the criteria.@@ -190,7 +191,8 @@ export default function SignupInvite() {onButtonPressed={async () => {const response = await verifySignupInvite({email,- code: token+ code: token,+ organizationId});if (response.status === 200) {const res = await response.json();