Review a pull request: React profile page
Not solvedA frontend PR renders user bios, stores a token and redirects after saving. Find the client-side defects.
- Level
- Foundational
- Estimated time
- ~20 min
- Points
- 0/65 pts
- Questions
- 0/0 answered
- OWASP
- A05:2025
- OWASP
- A01:2025
- OWASP
- A04:2025
- CWE
- CWE-79
- CWE
- CWE-601
- CWE
- CWE-922
app/profile/ProfilePage.tsx0/3 found
| import { useEffect, useState } from 'react' | ||
| import { api } from '@/lib/api' | ||
| export function ProfilePage({ username }: { username: string }) { | ||
| const [profile, setProfile] = useState<Profile | null>(null) | ||
| useEffect(() => { | ||
| + | api.login().then(({ accessToken }) => { | |
| + | localStorage.setItem('accessToken', accessToken) | |
| + | }) | |
| api.getProfile(username).then(setProfile) | ||
| }, [username]) | ||
| if (!profile) return <Spinner /> | ||
| return ( | ||
| <section> | ||
| <h1>{profile.displayName}</h1> | ||
| + | <div dangerouslySetInnerHTML={{ __html: profile.bio }} /> | |
| <FollowButton user={profile} /> | ||
| </section> | ||
| ) | ||
| } | ||
| export function afterSave() { | ||
| + | const next = new URLSearchParams(location.search).get('next') | |
| + | window.location.href = next | |
| } |
Click a line number to flag a defect. The review code appears when every defect is flagged with no false positives.