Skip to content

Commit 6e4b333

Browse files
committed
Enhance authentication flow by checking for an auth token in localStorage during user login. Update API endpoint references to include versioning in ApiKeyManager and api.js files, improving clarity and consistency across the application.
1 parent 97b3ebb commit 6e4b333

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

frontend/src/App.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ export default {
3838
},
3939
methods: {
4040
onUserLoggedIn() {
41-
this.isLoggedIn = true;
42-
this.currentProjectIdForConfigManager = null;
41+
const token = localStorage.getItem('authToken');
42+
if (token) {
43+
axios.defaults.headers.common['Authorization'] = `Token ${token}`;
44+
this.isLoggedIn = true;
45+
this.currentProjectIdForConfigManager = null;
46+
} else {
47+
console.error("Login event received, but no token found in localStorage.");
48+
this.handleLogout(true);
49+
}
4350
},
4451
async handleLogout(isSessionExpired = false) {
4552
if (isSessionExpired) {

frontend/src/components/ApiKeyManager.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<script>
4141
import axios from 'axios';
4242
43-
const API_KEYS_URL = '/api/core/api-keys/'; // Endpoint for APIKeyViewSet
43+
const API_KEYS_URL = '/api/v1/core/api-keys/'; // Corrected Endpoint with v1 prefix
4444
4545
export default {
4646
name: 'ApiKeyManager',

frontend/src/services/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_CORE_URL = '/api/core';
3+
const API_CORE_URL = '/api/v1/core';
44

55
// Utility for handling Axios responses, can be expanded (e.g., for error formatting)
66
const handleResponse = (response) => response.data;

0 commit comments

Comments
 (0)