Skip to content

Commit 2a45876

Browse files
committed
feat(profile): add API Keys section to profile navigation and migrate
redirects from client-side to server-side to improve reliability, security, and alignment with API keys flow. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent e1eab7f commit 2a45876

File tree

18 files changed

+1249
-1231
lines changed

18 files changed

+1249
-1231
lines changed

security-page-restructure-plan.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Security Page Restructure Plan
2+
3+
## Overview
4+
Split the current security page into two separate pages:
5+
1. **API Keys page** (`/api-keys`) - for Personal Access Token (PAT) management
6+
2. **Profile page** (`/profile`) - with a security section for active sessions
7+
8+
## Changes Required
9+
10+
### 1. Create API Keys Page (`/api-keys`)
11+
- Move PAT creation, listing, and revocation functionality from security page
12+
- Rename all "Personal Access Token" to "API Key" in UI text
13+
- Keep existing functionality but with updated terminology
14+
- Update page title, descriptions, and button text
15+
16+
### 2. Create Profile Page (`/profile`)
17+
- Create new profile page with tabbed interface:
18+
- **Usage tab** - move current usage page content (usage display, credit management)
19+
- **Security tab** - move active sessions management (web/CLI tabs) from security page
20+
- **Referrals tab** - move referral functionality from separate page
21+
- Keep all existing functionality from moved pages
22+
- Profile tab and Affiliate tab to be added later
23+
24+
### 3. Update Navigation
25+
- Update user dropdown: replace "Security", "Usage", and "Referrals" with single "Profile" link
26+
- Add "API Keys" link to user dropdown
27+
- Update any internal links that reference `/security`, `/usage`, `/referrals`, or `/affiliates`
28+
- Consider keeping separate referrals/affiliates pages that redirect to profile tabs
29+
30+
### 4. Update API Endpoints (Text Only)
31+
- Update log messages in API routes to use "API Key" instead of "Personal Access Token"
32+
- Keep all API functionality unchanged, only update user-facing text
33+
34+
### 5. File Changes
35+
- `web/src/app/api-keys/page.tsx` - new API keys page
36+
- `web/src/app/profile/page.tsx` - new profile page with usage and security tabs
37+
- `web/src/components/navbar/user-dropdown.tsx` - update navigation links
38+
- `web/src/app/api/api-keys/route.ts` - update log messages to use "API Key"
39+
- Remove `web/src/app/security/page.tsx` (or redirect to profile)
40+
- Update `web/src/app/usage/page.tsx` to redirect to profile page usage tab
41+
42+
## Implementation Steps
43+
1. Create new API keys page with PAT functionality
44+
2. Create new profile page with sessions functionality
45+
2. Create new profile page with usage and security tabs
46+
3. Update user dropdown navigation
47+
4. Update API route log messages
48+
5. Update usage page to redirect to profile
49+
6. Test both pages work correctly
50+
7. Remove old security page

web/next.config.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ const nextConfig = {
9696
permanent: false,
9797
destination: `${process.env.NEXT_PUBLIC_CODEBUFF_APP_URL}/:path*`,
9898
},
99+
{
100+
source: '/api-keys',
101+
destination: '/profile?tab=api-keys',
102+
permanent: true,
103+
},
104+
{
105+
source: '/usage',
106+
destination: '/profile?tab=usage',
107+
permanent: true,
108+
},
109+
{
110+
source: '/referrals',
111+
destination: '/profile?tab=referrals',
112+
permanent: true,
113+
},
99114
{
100115
source: '/discord',
101116
destination: 'https://discord.gg/mcWTGjgTj3',

web/src/app/api/api-keys/route.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ export async function GET(request: NextRequest) {
4343

4444
logger.info(
4545
{ userId, tokenCount: tokens.length },
46-
'Successfully retrieved Personal Access Tokens'
46+
'Successfully retrieved API Keys'
4747
)
4848
return NextResponse.json({ tokens }, { status: 200 })
4949
} catch (error) {
50-
logger.error({ error, userId }, 'Failed to retrieve Personal Access Tokens')
50+
logger.error({ error, userId }, 'Failed to retrieve API Keys')
5151
return NextResponse.json(
52-
{ error: 'Failed to retrieve Personal Access Tokens' },
52+
{ error: 'Failed to retrieve API Keys' },
5353
{ status: 500 }
5454
)
5555
}
@@ -98,21 +98,21 @@ export async function POST(request: NextRequest) {
9898

9999
logger.info(
100100
{ userId, tokenDisplay, expiresInDays },
101-
'Successfully created Personal Access Token'
101+
'Successfully created API Key'
102102
)
103103

104104
return NextResponse.json(
105105
{
106106
token: sessionToken, // Return full token with prefix already baked in
107107
expires: expires.toISOString(),
108-
message: 'Personal Access Token created successfully',
108+
message: 'API Key created successfully',
109109
},
110110
{ status: 201 }
111111
)
112112
} catch (error) {
113-
logger.error({ error, userId }, 'Failed to create Personal Access Token')
113+
logger.error({ error, userId }, 'Failed to create API Key')
114114
return NextResponse.json(
115-
{ error: 'Failed to create Personal Access Token' },
115+
{ error: 'Failed to create API Key' },
116116
{ status: 500 }
117117
)
118118
}

0 commit comments

Comments
 (0)