-
Notifications
You must be signed in to change notification settings - Fork 0
Replace mock login status with API integration #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces mock authentication logic with real API integration for user login status verification. The changes implement proper token-based authentication using localStorage and centralize API endpoint configuration.
- Removed hardcoded mock user data and replaced it with actual API calls to fetch user profiles
- Added centralized API endpoint configuration with environment variable support
- Enhanced error handling and token cleanup for authentication failures
Reviewed Changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/context/AuthContext.tsx | Replaced mock authentication logic with real API calls using token validation |
src/constants/env.ts | Added centralized API endpoint configuration with environment variable support |
const logout = async () => { | ||
try { | ||
await logoutUser(); | ||
await logoutUser(); // 通常のAPI logout |
Copilot
AI
Jul 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment contains Japanese text ('通常のAPI logout'). Consider using English for consistency with the rest of the codebase, such as '// Standard API logout'.
await logoutUser(); // 通常のAPI logout | |
await logoutUser(); // Standard API logout |
Copilot uses AI. Check for mistakes.
}, | ||
posts: { | ||
create: `${API_BASE_URL}/posts`, | ||
list:(id: string) => `${API_BASE_URL}/users/${id}/posts`, |
Copilot
AI
Jul 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Missing space after colon in the object property. Should be 'list: (id: string) =>' for consistent formatting.
list:(id: string) => `${API_BASE_URL}/users/${id}/posts`, | |
list: (id: string) => `${API_BASE_URL}/users/${id}/posts`, |
Copilot uses AI. Check for mistakes.
const userProfile = await fetchUserProfile(userId, token); | ||
setUser(userProfile); | ||
} catch (error) { | ||
console.error('Failed to fetch user profile:', error); |
Copilot
AI
Jul 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging the full error object may expose sensitive information in production. Consider logging only the error message or a sanitized version of the error.
console.error('Failed to fetch user profile:', error); | |
console.error('Failed to fetch user profile:', error instanceof Error ? error.message : String(error)); |
Copilot uses AI. Check for mistakes.
Description