Skip to content

Commit dffa5ad

Browse files
remyluslosiusclaude
andcommitted
refactor(frontend): Consolidate credential API endpoints to /api/system/credentials
Simplified credential API usage by removing v2 endpoint confusion and consolidating all credential operations to use /api/system/credentials. Changes: - Settings.tsx: Updated GET, POST, PUT, DELETE to use /api/system/credentials - AddHost.tsx: Updated system credential fetching endpoint - HostsEnhanced.tsx: Updated system credential fetching endpoint Why: - Application is in development/testing phase - no need for v1/v2 versioning - Frontend was inconsistently using /api/v2/credentials and /api/system/credentials - Backend already has unified implementation at /api/system/credentials - Reduces confusion and maintenance overhead Security: - No changes to authentication/authorization logic - All endpoints still require valid JWT tokens - Credential encryption unchanged - RBAC controls preserved Testing: Manual verification needed via Settings UI Related: System credentials migration from dual-table to unified_credentials 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 341845b commit dffa5ad

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

frontend/src/pages/hosts/AddHost.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ const AddHost: React.FC = () => {
307307
// Fetch system default credentials for display
308308
const fetchSystemCredentials = async () => {
309309
try {
310-
// WEEK 2 MIGRATION: Use v2 API with scope filter (trailing slash required)
311-
const response = await fetch('/api/v2/credentials/?scope=system', {
310+
// Use unified credentials API with scope filter
311+
const response = await fetch('/api/system/credentials?scope=system', {
312312
headers: {
313313
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`
314314
}

frontend/src/pages/hosts/HostsEnhanced.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,8 @@ const HostsEnhanced: React.FC = () => {
742742

743743
const fetchSystemCredentialsForEdit = async () => {
744744
try {
745-
// WEEK 2 MIGRATION: Use v2 API with scope filter (trailing slash required)
746-
const response = await api.get('/api/v2/credentials/?scope=system');
745+
// Use unified credentials API with scope filter
746+
const response = await api.get('/api/system/credentials?scope=system');
747747
const defaultCredential = response.find((cred: any) => cred.is_default);
748748

749749
if (defaultCredential) {

frontend/src/pages/settings/Settings.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ const Settings: React.FC = () => {
178178

179179
try {
180180
setLoading(true);
181-
// WEEK 2 MIGRATION: Use v2 API with scope filter and inactive toggle
181+
// Use unified credentials API with scope filter and inactive toggle
182182
const params = new URLSearchParams({
183183
scope: 'system',
184184
include_inactive: showInactive.toString()
185185
});
186-
const response = await api.get(`/api/v2/credentials/?${params}`);
186+
const response = await api.get(`/api/system/credentials?${params}`);
187187
setCredentials(response); // API directly returns array
188188
} catch (err: any) {
189189
setError('Failed to load system credentials');
@@ -343,8 +343,8 @@ const Settings: React.FC = () => {
343343
}
344344

345345
try {
346-
// WEEK 2 MIGRATION: Use v2 DELETE endpoint (trailing slash required)
347-
await api.delete(`/api/v2/credentials/${id}/`);
346+
// Use unified credentials API DELETE endpoint
347+
await api.delete(`/api/system/credentials/${id}`);
348348
setSuccess('Credential set deleted successfully');
349349
loadCredentials();
350350
} catch (err: any) {
@@ -359,17 +359,17 @@ const Settings: React.FC = () => {
359359
setLoading(true);
360360

361361
if (editingCredential) {
362-
// Update existing credential (keep using v1 PUT - already on unified_credentials)
362+
// Update existing credential using unified credentials API
363363
await api.put(`/api/system/credentials/${editingCredential.id}`, formData);
364364
setSuccess('Credential set updated successfully');
365365
} else {
366-
// WEEK 2 MIGRATION: Create new credential using v2 API (trailing slash required)
367-
const v2FormData = {
366+
// Create new credential using unified credentials API
367+
const createFormData = {
368368
...formData,
369369
scope: 'system',
370370
target_id: null
371371
};
372-
await api.post('/api/v2/credentials/', v2FormData);
372+
await api.post('/api/system/credentials', createFormData);
373373
setSuccess('Credential set created successfully');
374374
}
375375

0 commit comments

Comments
 (0)