Requested changes

This commit is contained in:
Daniel Hougaard
2024-08-24 11:00:05 +04:00
parent 28ecc37163
commit a2b994ab23
6 changed files with 14 additions and 18 deletions

View File

@@ -180,7 +180,7 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
encryptedPrivateKeyTag: z.string().trim(),
salt: z.string().trim(),
verifier: z.string().trim(),
metadata: z.string().optional()
tokenMetadata: z.string().optional()
}),
response: {
200: z.object({

View File

@@ -313,7 +313,7 @@ export const authSignupServiceFactory = ({
encryptedPrivateKeyIV,
encryptedPrivateKeyTag,
authorization,
metadata
tokenMetadata
}: TCompleteAccountInviteDTO) => {
const user = await userDAL.findUserByUsername(email);
if (!user || (user && user.isAccepted)) {
@@ -370,13 +370,13 @@ export const authSignupServiceFactory = ({
tx
);
if (metadata) {
const metadataObj = jwt.verify(metadata, appCfg.AUTH_SECRET) as TTokenMetadata;
if (tokenMetadata) {
const metadataObj = jwt.verify(tokenMetadata, appCfg.AUTH_SECRET) as TTokenMetadata;
if (
metadataObj.payload.userId !== user.id ||
metadataObj.payload.orgId !== orgMembership.orgId ||
metadataObj.type !== TokenMetadataType.InviteToProjects
metadataObj?.payload?.userId !== user.id ||
metadataObj?.payload?.orgId !== orgMembership.orgId ||
metadataObj?.type !== TokenMetadataType.InviteToProjects
) {
throw new UnauthorizedError({
message: "Malformed or invalid metadata token"

View File

@@ -37,5 +37,5 @@ export type TCompleteAccountInviteDTO = {
ip: string;
userAgent: string;
authorization: string;
metadata?: string;
tokenMetadata?: string;
};

View File

@@ -546,15 +546,11 @@ export const orgServiceFactory = ({
});
}
await projectMembershipDAL.insertMany(
projectIds.map((id) => ({ projectId: id, userId: inviteeUser.id })),
tx
);
for await (const projectId of projectIds) {
await projectMembershipDAL.create(
{
projectId,
userId: inviteeUser.id
},
tx
);
await addMembersToProject({
orgDAL,
projectDAL,

View File

@@ -93,7 +93,7 @@ export type CompleteAccountDTO = {
salt: string;
verifier: string;
password: string;
metadata?: string;
tokenMetadata?: string;
};
export type CompleteAccountSignupDTO = CompleteAccountDTO & {

View File

@@ -165,7 +165,7 @@ export default function SignupInvite() {
encryptedPrivateKeyTag,
salt: result.salt,
verifier: result.verifier,
metadata
tokenMetadata: metadata
});
// unset temporary signup JWT token and set JWT token