Authenticate routes.#31
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
This PR implements authentication guards for protected routes and adds a logout flow. The changes include server-side session management via a new Django logout endpoint, client-side middleware for route protection, and improved Last.fm callback handling with better async/await patterns.
- Route protection middleware that redirects unauthenticated users from
/music-mapto/login - Server and client-side logout functionality with proper state cleanup
- Improved async/await error handling in the Last.fm callback flow
Reviewed Changes
Copilot reviewed 9 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
backend/musicRecommendationService/views.py |
Added logout_view endpoint to clear Django session |
backend/musicRecommendationService/urls.py |
Registered new /logout/ route |
frontend/src/middleware.ts |
New middleware protecting /music-map and redirecting based on auth state |
frontend/src/lib/components/Navbar.tsx |
Updated signOut to call backend logout and clear client state |
frontend/src/app/services/lastfm_user.ts |
Added logoutUser function calling backend endpoint |
frontend/src/app/login/lastfm-callback/page.tsx |
Refactored to async/await with improved error handling |
frontend/src/lib/stores/auth-store.ts |
Zustand store for authentication state with localStorage persistence |
frontend/src/lib/providers/auth-store-provider.tsx |
React context provider for auth store |
.github/workflows/build-check.yml |
Updated to run build from frontend/ directory |
Comments suppressed due to low confidence (1)
backend/musicRecommendationService/views.py:15
- Import of 'get_session' is not used.
from .lastfm_stuff import get_session
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AndrewN4675
left a comment
There was a problem hiding this comment.
Looks great and Next.js built, just a Vercel error with finding the folder. Will fix it
This pull request guards routes with authentication and closes issue #20.
Key Changes:
backend/musicRecommendationService/urls.py: Added a logout/ route.backend/musicRecommendationService/views.py: Added logout_view to clear the Django session and return a JSON success response.frontend/src/middleware.ts: New middleware that protects authenticated routes (currently /music-map).frontend/src/app/services/lastfm_user.ts: Added logoutUser() which calls the backend logout/ endpoint.frontend/src/lib/components/Navbar.tsx: Updated signOut() to call logoutUser(), clear client-side auth state, remove local storage, and redirect appropriately.frontend/src/app/login/lastfm-callback/page.tsx: Improved Last.fm callback flow (async/await, error handling, and redirect logic).Frontend file moves/renames