mirror of
https://github.com/hanzoai/captable.git
synced 2026-10-16 14:21:29 +00:00
fix: re-invite member procedure
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { sendMemberInviteEmail } from "@/jobs/member-inivite-email";
|
||||
import { generatePasswordResetToken } from "@/lib/token";
|
||||
import { Audit } from "@/server/audit";
|
||||
import { checkMembership } from "@/server/auth";
|
||||
import {
|
||||
@@ -16,11 +17,10 @@ export const reInviteProcedure = withAuth
|
||||
const user = session.user;
|
||||
const trigger = getTriggerClient();
|
||||
|
||||
const { authTokenHash, expires, memberInviteTokenHash, token } =
|
||||
await generateInviteToken();
|
||||
const { expires, memberInviteTokenHash } = await generateInviteToken();
|
||||
|
||||
const { company, verificationToken, email } = await db.$transaction(
|
||||
async (tx) => {
|
||||
const { company, verificationToken, email, passwordResetToken } =
|
||||
await db.$transaction(async (tx) => {
|
||||
const { companyId } = await checkMembership({ session, tx });
|
||||
|
||||
const company = await tx.company.findFirstOrThrow({
|
||||
@@ -74,15 +74,6 @@ export const reInviteProcedure = withAuth
|
||||
},
|
||||
});
|
||||
|
||||
// next-auth verification token
|
||||
await tx.verificationToken.create({
|
||||
data: {
|
||||
identifier: email,
|
||||
token: authTokenHash,
|
||||
expires,
|
||||
},
|
||||
});
|
||||
|
||||
await Audit.create(
|
||||
{
|
||||
action: "member.re-invited",
|
||||
@@ -98,13 +89,15 @@ export const reInviteProcedure = withAuth
|
||||
tx,
|
||||
);
|
||||
|
||||
return { verificationToken, company, email };
|
||||
},
|
||||
);
|
||||
const { token: passwordResetToken } =
|
||||
await generatePasswordResetToken(email);
|
||||
|
||||
return { verificationToken, company, email, passwordResetToken };
|
||||
});
|
||||
|
||||
const payload = {
|
||||
verificationToken,
|
||||
token,
|
||||
passwordResetToken,
|
||||
email,
|
||||
company,
|
||||
user: {
|
||||
|
||||
Reference in New Issue
Block a user