Skip to content

Feature/addlogoutfunctionaity #34 issue part-2#45

Open
arpitasi1gh wants to merge 2 commits into
niharika-mente:mainfrom
arpitasi1gh:feature/addlogoutfunctionaity
Open

Feature/addlogoutfunctionaity #34 issue part-2#45
arpitasi1gh wants to merge 2 commits into
niharika-mente:mainfrom
arpitasi1gh:feature/addlogoutfunctionaity

Conversation

@arpitasi1gh

@arpitasi1gh arpitasi1gh commented Jun 11, 2026

Copy link
Copy Markdown

Related Issue

Fixes #34

Problem

Users could not properly sign out. The AuthContext had no logout method, and the Navbar had no logout button, leaving users unable to end their sessions.

Solution

  • Added logout() function to AuthContext that clears user state
  • Updated Navbar to display a "Logout" button when user is authenticated
  • Logout button clears user session and redirects to login page
  • Button positioned alongside "New Note" button for easy access

Result

Users can now:

  • Click "Logout" button in the navbar to sign out
  • Are automatically redirected to login page
  • Their session is properly cleared from application state

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@arpitasi1gh, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 22 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 888e8ce7-a283-4da4-a32a-c19c2fc6c58f

📥 Commits

Reviewing files that changed from the base of the PR and between 1bb5406 and 35a6475.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • frontend/src/components/Navbar.jsx
  • frontend/src/context/AuthContext.jsx
  • frontend/src/pages/Login.jsx
  • frontend/src/pages/Signup.jsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SparshM8

Copy link
Copy Markdown
Collaborator

Hey @arpitasi1gh, great work on the UI side of this! The layout looks clean, and the button is wired up perfectly to redirect the user.

I was looking through the code, and while the frontend state clears correctly, we have one critical logic gap we need to patch in frontend/src/context/AuthContext.jsx.

Right now, your logout function looks like this:

JavaScript
const logout = () => {
setUser(null);
};
This clears the user from React's memory, but it doesn't tell our backend to clear the JWT cookie or invalidate the token. If a user logs out, their browser still holds a valid authentication cookie!

Could you update the logout function to make an API call to our backend logout route before clearing the state? It should look something like this:

JavaScript
const logout = async () => {
try {
await api.post("/auth/logout"); // Or whatever your backend logout endpoint is
} catch (error) {
console.error("Logout API error:", error);
} finally {
setUser(null);
}
};
Next Steps:

Update the logout function in AuthContext.jsx to call the backend.

Resolve that merge conflict in Navbar.jsx by pulling the latest main branch.

Once those two things are done, I'll happily get this merged for you!

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.

Fix Authentication Error Handling and Add Logout Functionality

2 participants