From 3ff476465bec6cb83812090d09b716496798deb2 Mon Sep 17 00:00:00 2001 From: nael Date: Fri, 29 Mar 2024 07:28:48 +0100 Subject: [PATCH] :pencil2: Typo --- apps/client-ts/src/app/authenticate/page.tsx | 1 + .../hooks/mutations/useProfileMutation.tsx | 1 + packages/api/prisma/schema.prisma | 22 ++++++++++--------- .../api/src/@core/auth/auth.controller.ts | 2 +- packages/api/src/@core/auth/auth.service.ts | 14 ++++++++---- .../api/src/@core/auth/dto/create-user.dto.ts | 4 ++++ .../api/src/crm/company/company.module.ts | 1 - .../src/crm/company/services/attio/index.ts | 3 +-- .../src/crm/company/services/attio/mappers.ts | 2 +- 9 files changed, 31 insertions(+), 19 deletions(-) diff --git a/apps/client-ts/src/app/authenticate/page.tsx b/apps/client-ts/src/app/authenticate/page.tsx index 1d1af6b6f..1fb51beaf 100644 --- a/apps/client-ts/src/app/authenticate/page.tsx +++ b/apps/client-ts/src/app/authenticate/page.tsx @@ -57,6 +57,7 @@ const InnerAuthenticate = () => { last_name: user.name.last_name, email: user.emails[0].email, stytch_id_user: user.user_id, + strategy: 'b2c', id_organization: orgs && orgs[0].id_organization }); } diff --git a/apps/client-ts/src/hooks/mutations/useProfileMutation.tsx b/apps/client-ts/src/hooks/mutations/useProfileMutation.tsx index aacf58cb2..491b9383e 100644 --- a/apps/client-ts/src/hooks/mutations/useProfileMutation.tsx +++ b/apps/client-ts/src/hooks/mutations/useProfileMutation.tsx @@ -7,6 +7,7 @@ interface IProfileDto { last_name: string; email: string; stytch_id_user: string; + strategy: string; id_organization?: string } diff --git a/packages/api/prisma/schema.prisma b/packages/api/prisma/schema.prisma index f11f0ae6f..640ecbc4c 100644 --- a/packages/api/prisma/schema.prisma +++ b/packages/api/prisma/schema.prisma @@ -532,16 +532,18 @@ model tcg_users { /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model users { - id_user String @id(map: "pk_users") @db.Uuid - email String - password_hash String - first_name String - last_name String - created_at DateTime @default(now()) @db.Timestamp(6) - modified_at DateTime @default(now()) @db.Timestamp(6) - id_organization String? @db.Uuid - api_keys api_keys[] - organizations organizations? @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_5") + id_user String @id(map: "pk_users") @db.Uuid + email String + password_hash String + first_name String + last_name String + created_at DateTime @default(now()) @db.Timestamp(6) + modified_at DateTime @default(now()) @db.Timestamp(6) + id_organization String? @db.Uuid + id_stytch String? + identification_strategy String? + api_keys api_keys[] + organizations organizations? @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_5") @@index([id_organization], map: "fk_1_users") } diff --git a/packages/api/src/@core/auth/auth.controller.ts b/packages/api/src/@core/auth/auth.controller.ts index 1a975bb39..f2dd303f4 100644 --- a/packages/api/src/@core/auth/auth.controller.ts +++ b/packages/api/src/@core/auth/auth.controller.ts @@ -67,7 +67,7 @@ export class AuthController { @ApiResponse({ status: 404, description: 'User not found.' }) @Get('users/:stytchId') async getUser(@Param('stytchId') stytchId: string) { - return this.authService.getUser(stytchId); + return this.authService.getUserByStytchId(stytchId); } @ApiOperation({ operationId: 'getApiKeys', summary: 'Retrieve API Keys' }) diff --git a/packages/api/src/@core/auth/auth.service.ts b/packages/api/src/@core/auth/auth.service.ts index 014e378d1..a9ad3e7bd 100644 --- a/packages/api/src/@core/auth/auth.service.ts +++ b/packages/api/src/@core/auth/auth.service.ts @@ -32,12 +32,12 @@ export class AuthService { handleServiceError(error, this.logger); } } - - async getUser(stytchId: string) { + async getUserByStytchId(stytchId: string) { try { return await this.prisma.users.findUnique({ where: { - stytch_id: stytchId, + id_stytch: stytchId, + identification_strategy: 'b2c' }, }); } catch (error) { @@ -87,7 +87,13 @@ export class AuthService { });*/ return await this.prisma.users.create({ data: { - ...user, + id_stytch: user.stytch_id_user, + identification_strategy: user.strategy, + first_name: user.first_name, + last_name: user.last_name, + email: user.email, + password_hash: '', + created_at: new Date(), id_user: id_user || uuidv4(), }, }); diff --git a/packages/api/src/@core/auth/dto/create-user.dto.ts b/packages/api/src/@core/auth/dto/create-user.dto.ts index 0a8f34657..8acc2a15f 100644 --- a/packages/api/src/@core/auth/dto/create-user.dto.ts +++ b/packages/api/src/@core/auth/dto/create-user.dto.ts @@ -8,6 +8,10 @@ export class CreateUserDto { @ApiProperty() email: string; @ApiProperty() + stytch_id_user: string; + @ApiProperty() + strategy: string; + @ApiPropertyOptional() password_hash: string; @ApiPropertyOptional() id_organisation?: string; diff --git a/packages/api/src/crm/company/company.module.ts b/packages/api/src/crm/company/company.module.ts index a352d865c..c7eab994c 100644 --- a/packages/api/src/crm/company/company.module.ts +++ b/packages/api/src/crm/company/company.module.ts @@ -1,4 +1,3 @@ -import { AttioService } from './services/attio'; import { Module } from '@nestjs/common'; import { CompanyController } from './company.controller'; import { SyncService } from './sync/sync.service'; diff --git a/packages/api/src/crm/company/services/attio/index.ts b/packages/api/src/crm/company/services/attio/index.ts index 0d091dbc9..a83d1bbf3 100644 --- a/packages/api/src/crm/company/services/attio/index.ts +++ b/packages/api/src/crm/company/services/attio/index.ts @@ -3,8 +3,6 @@ import { Injectable } from '@nestjs/common'; import axios from 'axios'; import { CrmObject, - AttioCompanyInput, - AttioCompanyOutput, } from '@crm/@utils/@types'; import { PrismaService } from '@@core/prisma/prisma.service'; import { LoggerService } from '@@core/logger/logger.service'; @@ -13,6 +11,7 @@ import { EncryptionService } from '@@core/encryption/encryption.service'; import { ApiResponse } from '@@core/utils/types'; import { ICompanyService } from '@crm/company/types'; import { ServiceRegistry } from '../registry.service'; +import { AttioCompanyInput, AttioCompanyOutput } from './types'; @Injectable() export class AttioService implements ICompanyService { diff --git a/packages/api/src/crm/company/services/attio/mappers.ts b/packages/api/src/crm/company/services/attio/mappers.ts index af858e958..0a8ae166b 100644 --- a/packages/api/src/crm/company/services/attio/mappers.ts +++ b/packages/api/src/crm/company/services/attio/mappers.ts @@ -1,4 +1,4 @@ -import { AttioCompanyInput, AttioCompanyOutput } from '@crm/@utils/@types'; +import { AttioCompanyInput, AttioCompanyOutput } from './types'; import { UnifiedCompanyInput, UnifiedCompanyOutput,