({ user_id = null } = {})
| 3409 | } |
| 3410 | |
| 3411 | static async revokeApiKey({ user_id = null } = {}) { |
| 3412 | try { |
| 3413 | const body = {}; |
| 3414 | if (user_id) { |
| 3415 | body.user_id = user_id; |
| 3416 | } |
| 3417 | |
| 3418 | const response = await request(`${host}/api/accounts/api-keys/revoke/`, { |
| 3419 | method: 'POST', |
| 3420 | body, |
| 3421 | }); |
| 3422 | |
| 3423 | // If the backend returned an updated user, refresh the users store |
| 3424 | try { |
| 3425 | if (response && response.user) { |
| 3426 | useUsersStore.getState().updateUser(response.user); |
| 3427 | } |
| 3428 | } catch (e) { |
| 3429 | // ignore store update errors |
| 3430 | } |
| 3431 | |
| 3432 | return response; |
| 3433 | } catch (e) { |
| 3434 | errorNotification('Failed to revoke API key', e); |
| 3435 | } |
| 3436 | } |
| 3437 | |
| 3438 | static async updateUser(id, body, self = false) { |
| 3439 | try { |
no test coverage detected