From 510c9af6de1391e9ea59e029d6f44804aa19bb0f Mon Sep 17 00:00:00 2001 From: Rachid Flih Date: Mon, 29 Jul 2024 17:14:12 +0100 Subject: [PATCH] feat: force unique email on signup --- docs/logo/postman-icon.png | Bin 0 -> 3932 bytes packages/api/scripts/seed.sql | 6 +++--- packages/api/src/@core/auth/auth.service.ts | 11 ++++------- .../api/src/@core/projects/projects.service.ts | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 docs/logo/postman-icon.png diff --git a/docs/logo/postman-icon.png b/docs/logo/postman-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..53297a874f1390948d8a2e5623b45b69b240e932 GIT binary patch literal 3932 zcmai1dsIw&`~U8}=h9`m5Sk>7h;B6HP{(aXr<8<|i1eBvz0U8@DJPO{dv{f$LY?Yx z6zX)PA~{I2Q74gdOW`o13lcS5Mtic```tP3dDrjv`{&*3S?jrdp3mCPTKoIm&yylq z=dPzST?YW5x7x$i8vvLwVW5RD>dtR-?lOwCd*#}d092*xk~`Rp4~2TWyMT)=GkO`v zRO031#^_H$qQ8Wu=`Zc~)uri!DZBcEL<1w^UnV&Ad#~FF7DqRqS{#-GfPU+0*Oflu zFFyVH(!1N)&~@91z9Cv#>u~x0;sg-8sixpr(^V6#na(BUcF%ESR>ES5r}ewj_sum$ zHfUz(I%~^1X~ms!gZ=bPDgv5UUN(N=p!ge4^VEcmZ{xmk9qL0{!$Bf_t`Q^#|g2(i)o)+V|NT$dI>sqfBLTW>4qFMOh zJeD(+0B$g5o4Ij(y(j?t+{hPD+EAxC_aSA1)Qe_`$u2+ypS}ILvCyz9&*7`v1!~Yz zfjZsBWBd-JD$UH;zsfSY>$%`RRpg;xfY=zKK@BFJS8;vg(3(dS7^jBO)uW zjz>K#y?EH!4@&b;YkxkNUAUZ#PXdT6|GLI~FU-SsJl3anOp@@you{`%LYOJaV2Zk5 z2^ph+F<#C}1pM>*)Y*l&k%+t4<;5*g7{^&JB!NkOb)B==Clgt>kQb!_)Q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k;?T|X{j`u+23EK5%iv*-Qm(4x&D} zH%*vVSk!XPmOQy%JbL+W5<)c~#4nL&SFsc7jT1o23Gv|`BVe?~;SN@w~7Bp=)G6R+}8 z!PK7XX7mftTc{BgsuW$uZYwM=ESWc-X=X=T_*5#-L|LVaP9lOeeVuMT4{~Vf^!(bn z=%h{K`sb5|-UV~k7INgjAqUkDwJ`dgF9IktVnQ5|%pvBH3dfdHt6~kR? z52b#m2*aE?;jzC`)kyuQcSNmq&|P^LHdez4|JcYFnja&UU75wSwA3`e7Di{NUd~sQ zkTAIqx6iUg>>ikNNBDyIt>)a*Tj4W)r$rp+vyG9r(EIv?&+{z#B^J3UW-C=oDn4Ln zR!z74+y4Ey$a93&TdEwJFEODvFyEx&BC4Ssth_dRHy0sRq>cNP-XvHAAVJUwhM z72AO^e#|81dJ%vm(Ud6e^Y;LOWvWPM=**=mwtl#Q?0eST#?T+jW3!8wjb&ZzWKLZs z20_AduIKW;W0Qr&P|X209noRR;TwUVo;5_fem*;iE6%w1M!FQ6#xHZve7uOcPaeVn zh`_67I&}rHf{xqDPCs^Iq7wL=snUPB#IJ(pTMG7qgbx;!`mU3w_~^_k&kf{D{d`tE z50hnCQ9%sWV!G`2i=EQZnDeZo2AJQsN70we%M9vOZr1KngaJz#0gAIaiK}K9? zS+den3kwmcZe69zGX+mxX`R~IbNC+QgAumaR)s;-J8nyKH%Rtx=rNBHm*FarnqoUik^Ra`A=m0mvR z1Ui8E7dZoJ%F1a>9u`m91>qAD{}l0Nh+y`Gza-QQXB+BcqW>zboZtxRFv3jx{}%e! zaAqB#_u+lTPswYBvhgAAF8z`(EZ!GeD*L0)#?@lYz3}3j=;A2Kzn9fo{1(;{G+d9{a IF0#0P0o(Fic>n+a literal 0 HcmV?d00001 diff --git a/packages/api/scripts/seed.sql b/packages/api/scripts/seed.sql index 0f4451e45..6bd5a3ec2 100644 --- a/packages/api/scripts/seed.sql +++ b/packages/api/scripts/seed.sql @@ -7,6 +7,6 @@ INSERT INTO connector_sets (id_connector_set, crm_hubspot, crm_zoho, crm_pipedri ('aed0f856-f802-4a79-8640-66d441581a99', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); INSERT INTO projects (id_project, name, sync_mode, id_user, id_connector_set) VALUES - ('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', '1709da40-17f7-4d3a-93a0-96dc5da6ddd7'), - ('4c641a21-a7f8-4ffe-b7e8-e7d32db87557', 'Project 2', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', '852dfff8-ab63-4530-ae49-e4b2924407f8'), - ('2b198012-c79c-4bb6-971e-9635830e8c15', 'Project 3', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', 'aed0f856-f802-4a79-8640-66d441581a99'); + ('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', 'pull', '0ce39030-2901-4c56-8db0-5e326182ec6b', '1709da40-17f7-4d3a-93a0-96dc5da6ddd7'), + ('4c641a21-a7f8-4ffe-b7e8-e7d32db87557', 'Project 2', 'pull', '0ce39030-2901-4c56-8db0-5e326182ec6b', '852dfff8-ab63-4530-ae49-e4b2924407f8'), + ('2b198012-c79c-4bb6-971e-9635830e8c15', 'Project 3', 'pull', '0ce39030-2901-4c56-8db0-5e326182ec6b', 'aed0f856-f802-4a79-8640-66d441581a99'); diff --git a/packages/api/src/@core/auth/auth.service.ts b/packages/api/src/@core/auth/auth.service.ts index 8c7722446..ebd9461b5 100644 --- a/packages/api/src/@core/auth/auth.service.ts +++ b/packages/api/src/@core/auth/auth.service.ts @@ -10,6 +10,7 @@ import { PrismaService } from '../@core-services/prisma/prisma.service'; import { CreateUserDto } from './dto/create-user.dto'; import { LoginDto } from './dto/login.dto'; import { VerifyUserDto } from './dto/verify-user.dto'; +import { ConflictException } from '@nestjs/common'; @Injectable() export class AuthService { @@ -67,12 +68,8 @@ export class AuthService { }); if (foundUser) { - new AuthError({ - name: 'EMAIL_ALREADY_EXISTS_ERROR', - message: `Email already exists for user with email=${user.email}`, - }); + throw new ConflictException(`Email already exists. Try resetting your password.`); } - return await this.createUser(user); } catch (error) { throw error; @@ -95,7 +92,7 @@ export class AuthService { }, }); await this.projectService.createProject({ - name: 'Project 1', + name: 'My Project', id_user: user_.id_user, }); return user_; @@ -327,4 +324,4 @@ export class AuthService { throw error; } } -} +} \ No newline at end of file diff --git a/packages/api/src/@core/projects/projects.service.ts b/packages/api/src/@core/projects/projects.service.ts index ebcac8513..eb1d53961 100644 --- a/packages/api/src/@core/projects/projects.service.ts +++ b/packages/api/src/@core/projects/projects.service.ts @@ -66,7 +66,7 @@ export class ProjectsService { const res = await this.prisma.projects.create({ data: { name: data.name, - sync_mode: 'pool', + sync_mode: 'pull', id_project: uuidv4(), id_user: data.id_user, id_connector_set: cSet.id_connector_set,