DocSpace-client/packages/common/api/user/index.js

75 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-12-04 08:38:15 +00:00
import { request, setWithCredentialsStatus } from "../client";
export function login(userName, passwordHash, session) {
const data = {
userName,
passwordHash,
session,
};
return request({
method: "post",
url: "/authentication",
2022-03-15 11:33:21 +00:00
skipLogout: true,
data,
});
}
2021-03-24 13:49:42 +00:00
export function thirdPartyLogin(SerializedProfile) {
return request({
method: "post",
url: "authentication",
2021-03-24 13:49:42 +00:00
data: { SerializedProfile },
});
}
export function logout() {
return request({
method: "post",
url: "/authentication/logout",
});
}
export function checkConfirmLink(data) {
return request({
method: "post",
url: "/authentication/confirm",
data,
});
2020-09-30 18:20:51 +00:00
}
2020-12-04 08:38:15 +00:00
export function checkIsAuthenticated() {
return request({
method: "get",
url: "/authentication",
withCredentials: true,
}).then((state) => {
setWithCredentialsStatus(state);
2020-12-04 11:21:51 +00:00
return state;
2020-12-04 08:38:15 +00:00
});
}
export function loginWithTfaCode(userName, passwordHash, code) {
const data = {
userName,
passwordHash,
code,
};
return request({
method: "post",
url: `/authentication/${code}`,
skipLogout: true,
data,
});
}
2022-12-09 07:40:38 +00:00
export function loginWithConfirmKey(data) {
return request({
method: "post",
url: `/authentication`,
2022-12-09 07:40:38 +00:00
skipLogout: true,
data,
});
}