Fixed bounce handling
This commit is contained in:
@@ -25,8 +25,8 @@ class APIClient {
|
||||
return `${protocol}//${hostname}:8000`;
|
||||
}
|
||||
|
||||
// If running in production, assume API is on port 8000
|
||||
return `${protocol}//${hostname}:8000`;
|
||||
// If running in production behind a reverse proxy, use /api path
|
||||
return `${protocol}//${hostname}/api`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,16 +104,18 @@ class APIClient {
|
||||
return this.request('/');
|
||||
}
|
||||
|
||||
// Authentication API
|
||||
async login(username, password) {
|
||||
// Don't include Authorization header for login
|
||||
const tempHeaders = { ...this.headers };
|
||||
delete tempHeaders['Authorization'];
|
||||
|
||||
const response = await this.request('/auth/login', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password
|
||||
})
|
||||
headers: tempHeaders,
|
||||
body: JSON.stringify({ username, password })
|
||||
});
|
||||
|
||||
// Set the token from the response
|
||||
if (response.access_token) {
|
||||
this.setToken(response.access_token);
|
||||
}
|
||||
@@ -126,41 +128,16 @@ class APIClient {
|
||||
await this.request('/auth/logout', {
|
||||
method: 'POST'
|
||||
});
|
||||
} catch (error) {
|
||||
// Ignore logout errors, we'll clear the token anyway
|
||||
} finally {
|
||||
// Clear token even if logout fails
|
||||
this.clearToken();
|
||||
}
|
||||
this.clearToken();
|
||||
}
|
||||
|
||||
async getCurrentUser() {
|
||||
return this.request('/auth/me');
|
||||
}
|
||||
|
||||
// User management API
|
||||
async getUsers() {
|
||||
return this.request('/users');
|
||||
}
|
||||
|
||||
async createUser(userData) {
|
||||
return this.request('/users', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(userData)
|
||||
});
|
||||
}
|
||||
|
||||
async updateUser(userId, userData) {
|
||||
return this.request(`/users/${userId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(userData)
|
||||
});
|
||||
}
|
||||
|
||||
async deleteUser(userId) {
|
||||
return this.request(`/users/${userId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
}
|
||||
|
||||
// Mailing Lists API
|
||||
async getLists() {
|
||||
return this.request('/lists');
|
||||
@@ -255,7 +232,32 @@ class APIClient {
|
||||
});
|
||||
}
|
||||
|
||||
// Bounce management API
|
||||
// User Management API
|
||||
async getUsers() {
|
||||
return this.request('/users');
|
||||
}
|
||||
|
||||
async createUser(userData) {
|
||||
return this.request('/users', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(userData)
|
||||
});
|
||||
}
|
||||
|
||||
async updateUser(userId, userData) {
|
||||
return this.request(`/users/${userId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(userData)
|
||||
});
|
||||
}
|
||||
|
||||
async deleteUser(userId) {
|
||||
return this.request(`/users/${userId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
}
|
||||
|
||||
// Bounce Management API
|
||||
async getMemberBounces(memberId) {
|
||||
return this.request(`/members/${memberId}/bounces`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user