Skip to content

MSPCA 55: Sign-in flow - #38

Merged
psmolyan merged 38 commits into
mainfrom
ps/mspca-55-sign-in
Nov 22, 2026
Merged

psmolyan merged 38 commits into
mainfrom
ps/mspca-55-sign-in

Conversation

@psmolyan

@psmolyan psmolyan commented Nov 18, 2026 •

Copy link
Copy Markdown

ℹ️ Issue

Closes MSPCA-55

Stacked on #30 (MSPCA-46), where MSPCA-51 was merged. Once #30 merges, the base switches to main.

📝 Description

Adds email/password sign-in with Cognito. Pages now use the signed-in user instead of the ?volunteerId= query param.

Backend

  • Uncommented the TODO lines in CognitoJWTGuard, so all non-@Public() routes now require a valid access token. Un-skipped its tests
  • Added findByCognitoSubOrFail to the volunteer, coordinator and owner services
  • Added AuthModule with GET /api/auth/me. It reads the token payload with cognitoService.getUser(req), uses the user's Cognito group to pick the right service, and returns { role, user }

Frontend

  • Added getMe() to apiClient (the fetchAuthSession interceptor was already on the base branch)
  • Added UserProvider / useCurrentUser(), following the SSF example, to load the signed-in user from /me
  • Added the sign-in page from the Lo-Fi (desktop and mobile), and RequireAuth, which sends signed-out users to /sign-in. Replaced Amplify's built-in <Authenticator> form
  • The Navbar shows the signed-in user's initials
  • AnimalModal uses the signed-in volunteer's ID. Removed useVolunteerId and parseVolunteerId

Important Notes

  • Local setup: the backend needs AUTH_DISABLED=false, and the frontend needs VITE_COGNITO_USER_POOL_ID and VITE_COGNITO_USER_POOL_CLIENT_ID (same values as the backend's COGNITO_ ones). Confirming new accounts needs AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY. Postman requests to protected routes now need a bearer token
  • To test a coordinator, I temporarily removed the @mspca.org check in CreateCoordinatorDto locally. That change isn't in this PR
  • Remember me, Forgot password and Create Account are shown to match the Lo-Fi, but not implemented
  • The Lo-Fi uses the envelope icon on the password field too, so I matched it
  • There's a temporary Sign Out button in the Navbar for testing (marked with a TODO)
  • Unconfirmed accounts currently see nothing happen on Log in. Handling signIn's nextStep is left for a future ticket (TODO in handleSubmit)

✔️ Verification

Backend (npx jest), frontend (npx vitest run --root apps/frontend), lint, and typecheck all pass for both apps.

Sign-in page (desktop and mobile)
image

image

A failed login displays an error
image

Volunteer: initials in the Navbar, and /me returning their record (TV for Test Volunteer)
image
image

Coordinator: initials in the Navbar, and /me returning their record (TC for Test Coordinator)
image
image

Apply is disabled for coordinators
image

Also checked: reloading keeps you signed in, signed-out visits redirect to /sign-in and return you to that page after signing in, and /api/auth/me without a token returns 401

🏕️ (Optional) Future Work / Notes

  • Owner sign-in (next sem) (new password on first login)
  • Remember me, Forgot password, Create Account, and a sign-out button
  • Restricting pages by role

shreeyaadhikari and others added 29 commits October 24, 2026 23:01
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@psmolyan
psmolyan requested a review from dburkhart07 November 18, 2026 23:10

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really good initial pass through. such a well structured PR, a lot of very small nits. core logic looks so good though. nice job polina!!! 🐼 🐈‍⬛

Comment thread apps/frontend/src/pages/SignIn.tsx Resolved
Comment thread apps/frontend/src/pages/SignIn.tsx Resolved
Comment thread apps/frontend/src/pages/SignIn.tsx Resolved
Comment thread apps/frontend/src/pages/SignIn.tsx Resolved
Comment thread apps/frontend/src/components/Navbar.tsx Resolved

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 small documentation requests

Comment thread apps/frontend/src/auth/userContext.tsx Resolved
Comment thread apps/frontend/src/auth/userContext.tsx Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…frontend-endpoint' into ps/mspca-55-sign-in

# Conflicts:
#	apps/frontend/src/components/Navbar.tsx
#	apps/frontend/src/components/modals/AnimalModal.tsx
#	apps/frontend/src/utils/useVolunteerId.spec.tsx
#	apps/frontend/src/utils/volunteer.ts

@shreeyaadhikari shreeyaadhikari left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is so clean polina <3 !! just a couple nits

Comment thread apps/frontend/src/app.tsx Resolved
Base automatically changed from pk/mspca-46-animal-availability-frontend-endpoint to main November 22, 2026 19:33

@shreeyaadhikari shreeyaadhikari left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great pr polina !!

# Conflicts:
#	apps/frontend/src/api/apiClient.ts
#	apps/frontend/src/app.tsx
#	apps/frontend/src/components/Navbar.tsx
#	apps/frontend/src/components/modals/AnimalModal.tsx
#	apps/frontend/src/routes.ts
#	apps/frontend/src/types.ts
#	apps/frontend/src/utils/volunteer.spec.ts
#	apps/frontend/src/utils/volunteer.ts

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtmmmmm

@psmolyan
psmolyan merged commit 59803e6 into main Nov 22, 2026
12 checks passed
@psmolyan
psmolyan deleted the ps/mspca-55-sign-in branch November 22, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants