mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-21 01:05:30 +00:00
ability to revoke API keys, fixed bug showing another user's api key in the UI
This commit is contained in:
parent
64cbe0cc36
commit
5785fef4df
2 changed files with 89 additions and 14 deletions
|
|
@ -2904,6 +2904,33 @@ export default class API {
|
|||
}
|
||||
}
|
||||
|
||||
static async revokeApiKey({ user_id = null } = {}) {
|
||||
try {
|
||||
const body = {};
|
||||
if (user_id) {
|
||||
body.user_id = user_id;
|
||||
}
|
||||
|
||||
const response = await request(`${host}/api/accounts/api-keys/revoke/`, {
|
||||
method: 'POST',
|
||||
body,
|
||||
});
|
||||
|
||||
// If the backend returned an updated user, refresh the users store
|
||||
try {
|
||||
if (response && response.user) {
|
||||
useUsersStore.getState().updateUser(response.user);
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore store update errors
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
errorNotification('Failed to revoke API key', e);
|
||||
}
|
||||
}
|
||||
|
||||
static async updateUser(id, body) {
|
||||
try {
|
||||
const response = await request(`${host}/api/accounts/users/${id}/`, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue