Skip to content

Implement auto logout#341

Open
lyannne wants to merge 7 commits intomainfrom
implement-auto-logout
Open

Implement auto logout#341
lyannne wants to merge 7 commits intomainfrom
implement-auto-logout

Conversation

@lyannne
Copy link
Collaborator

@lyannne lyannne commented Feb 26, 2026

ℹ️ Issue

Closes #322

📝 Description

Changes made to the code:

  1. Added useEffect in authContext.tsx to start/clear the 8 hour timer on login/logout (respectively)
  2. Added logout method in backend controller and service to clear cookies
  3. Added testing for new backend route

✔️ Verification

What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.

  • I ran the backend with a 1 minute timer to test, and it auto logged me out after a minute!

Test Changes

If your new feature required some test to be changed or added to fit the new functionality or changes please document these changes here.

N/A

🏕️ (Optional) Future Work / Notes

Noticed that /auth/refresh endpoint does not exist for the refresh token; will need to be made in the future.

Copilot AI review requested due to automatic review settings February 26, 2026 19:04
@lyannne lyannne linked an issue Feb 26, 2026 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements an 8-hour auto-logout mechanism in the frontend auth context and adds a backend logout endpoint/service method to clear auth cookies (and optionally invalidate the Cognito session).

Changes:

  • Frontend: adds an 8-hour setTimeout tied to authentication state to auto-trigger logout.
  • Backend: adds POST /auth/logout to clear auth cookies and an AuthService.logout() method that calls Cognito globalSignOut.
  • Backend tests: adds unit tests for the new AuthService.logout() behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
frontend/src/context/auth/authContext.tsx Starts/clears an 8-hour timer based on isAuthenticated to auto-call logout()
backend/src/auth/auth.service.ts Adds a logout service method that attempts Cognito globalSignOut
backend/src/auth/auth.controller.ts Adds POST /auth/logout to clear cookies and attempt Cognito session invalidation
backend/src/auth/test/auth.service.spec.ts Adds unit tests for AuthService.logout()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

DEV Implement Auto Logout

2 participants