提交 ce0e69d9 编写于 作者: B Boris Sekachev 提交者: Nikita Manovich

Logout API method, fixed deleteTask method (#550)

上级 59cd9260
......@@ -73,6 +73,10 @@
await serverProxy.server.login(username, password);
};
cvat.server.logout.implementation = async () => {
await serverProxy.server.logout();
};
cvat.users.get.implementation = async (filter) => {
checkFilter(filter, {
self: isBoolean,
......
......@@ -117,6 +117,19 @@
.apiWrapper(cvat.server.login, username, password);
return result;
},
/**
* Method allows to logout from the server
* @method logout
* @async
* @memberof module:API.cvat.server
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ServerError}
*/
async logout() {
const result = await PluginRegistry
.apiWrapper(cvat.server.logout);
return result;
},
},
/**
* Namespace is used for getting tasks
......
......@@ -178,6 +178,22 @@
setCookie(authentificationResponse);
}
async function logout() {
const { backendAPI } = window.cvat.config;
try {
await Axios.get(`${backendAPI}/auth/logout`, {
proxy: window.cvat.config.proxy,
});
} catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code;
throw new window.cvat.exceptions.ServerError(
'Could not logout from the server',
code,
);
}
}
async function getTasks(filter = '') {
const { backendAPI } = window.cvat.config;
......@@ -309,7 +325,7 @@
proxy: window.cvat.config.proxy,
});
} catch (errorData) {
deleteTask(response.data.id);
await deleteTask(response.data.id);
const code = errorData.response ? errorData.response.status : errorData.code;
throw new window.cvat.exceptions.ServerError(
'Could not put data to the server',
......@@ -320,7 +336,7 @@
try {
await wait(response.data.id);
} catch (createException) {
deleteTask(response.data.id);
await deleteTask(response.data.id);
throw createException;
}
......@@ -497,6 +513,7 @@
share,
exception,
login,
logout,
}),
writable: false,
},
......
......@@ -1065,7 +1065,7 @@
};
Task.prototype.delete.implementation = async function () {
serverProxy.tasks.deleteTask(this.id);
await serverProxy.tasks.deleteTask(this.id);
};
Task.prototype.frames.get.implementation = async function (frame) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册