Repository navigation
Conversation
…lunteer-endpoint # Conflicts: # apps/backend/src/volunteers/volunteers.controller.spec.ts # apps/backend/src/volunteers/volunteers.controller.ts # apps/backend/src/volunteers/volunteers.service.spec.ts # apps/backend/src/volunteers/volunteers.service.ts
Creates the Cognito user with the FosterVolunteer role first, then saves the volunteer as pending with the returned sub. A Cognito failure leaves no Postgres row; duplicate emails return 409. - Add CreateVolunteerDto with validation matching column lengths - Add cognito_sub column (default '') and migration - Mark the route @public() so volunteers can sign up without a token - Register the ReplaceVolunteerActiveWithStatus migration from MSPCA-7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unt-by-id' into jw/mspca-20-create-volunteer-endpoint # Conflicts: # apps/backend/src/config/migrations.ts # apps/backend/src/volunteers/volunteers.controller.spec.ts # apps/backend/src/volunteers/volunteers.controller.ts # apps/backend/src/volunteers/volunteers.service.spec.ts # apps/backend/src/volunteers/volunteers.service.ts
Delete the Cognito user if the Postgres save, the group assignment, or the sub lookup fails, so a retry with the same email is not rejected as a duplicate. Lowercase volunteer emails before the duplicate check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unt-by-id' into jw/mspca-20-create-volunteer-endpoint
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unt-by-id' into jw/mspca-20-create-volunteer-endpoint
dburkhart07
left a comment
There was a problem hiding this comment.
a lot of comments, but most are just nits. learned a lot about cognito for this. very detailed pr so far, ty justin! 🐊
| @MaxLength(255) | ||
| lastName!: string; | ||
|
|
||
| @IsString() |
There was a problem hiding this comment.
can we get rid of this and use @IsPhoneNumber like in the edit volunteers dto (this should be in the main branch as of writing this comment)
| @MaxLength(20) | ||
| phone!: string; | ||
|
|
||
| @IsOptional() |
|
|
||
| @IsOptional() | ||
| @IsString() | ||
| notes?: string; |
There was a problem hiding this comment.
can we add IsNotEmpty for this as well? This way we can't initialize the notes to "", but rather null instead if nothing is provided
|
|
||
| @IsOptional() | ||
| @IsBoolean() | ||
| completedCanineTraining?: boolean; |
There was a problem hiding this comment.
I think this field is something that coordinators would fill in, so it may be best to not include this field right now, and initialize it to false.
| } | ||
| } | ||
|
|
||
| async deleteUser(email: string): Promise<void> { |
There was a problem hiding this comment.
this will make our lives easier for a ticket next week, so thanks for adding this!
| it('creates the Cognito user with the FosterVolunteer role', async () => { | ||
| await service.create(dto); | ||
|
|
||
| expect(cognitoService.createUser).toHaveBeenCalledWith({ |
There was a problem hiding this comment.
lets make sure this was only called once and repo.save only called once
| }); | ||
| }); | ||
|
|
||
| it('saves the volunteer as pending with a signed waiver and the Cognito sub', async () => { |
There was a problem hiding this comment.
same thing here with only call and save once
| }, | ||
| ); | ||
|
|
||
| it('lowercases the email before checking for duplicates and creating the user', async () => { |
There was a problem hiding this comment.
only called once for createUser and save
| ); | ||
| }); | ||
|
|
||
| it('deletes the Cognito user and rethrows when the Postgres save fails', async () => { |
There was a problem hiding this comment.
lets make sure createUser was called here too
| ); | ||
| }); | ||
|
|
||
| it('logs the orphaned Cognito sub and rethrows the save error when the cleanup also fails', async () => { |
There was a problem hiding this comment.
createUser called once, repo.save called once, deleteUser called once
ℹ️ Issue
Closes MSPCA-20
📝 Description
Adds
POST /api/volunteersso foster volunteers can sign up. It creates the user in Cognito with theFosterVolunteerrole, then saves the volunteer in Postgres with the returnedsub, asPendinguntil a coordinator approves them (MSPCA-17). Returns 201, 400 for invalid fields, or 409 if the email is taken.sub, group assignment, or the DB save), the Cognito user is deleted so the person can retry with the same email.@Public(), the first in the backend, since volunteers have no token yet when signing up.statusandmostRecentWaiverSignedcan't be set by the client.cognito_subcolumn (NOT NULL DEFAULT '') with a migration.✔️ Verification
CognitoServicecleanup, with Cognito mocked. All 233 backend tests pass, and lint, format, and typecheck are clean.us-east-2) and local Postgres with all migrations applied:status: Pending,mostRecentWaiverSigned: true, and acognitoSub. The user shows up in Cognito asFORCE_CHANGE_PASSWORDin theFosterVolunteergroup, and itssubmatches the row.status,cognitoSub, andmostRecentWaiverSignedin the body are ignored.AdminCreateUserrejects it) and aFosterVolunteergroup. SetAUTH_DISABLED=false, theCOGNITO_*IDs, and AWS keys withAdminCreateUser,AdminAddUserToGroup, andAdminDeleteUser, then:🏕️ (Optional) Future Work / Notes
N/A