2020-12-04 08:38:15 +00:00
|
|
|
import { request, setWithCredentialsStatus } from "../client";
|
2019-11-14 13:37:41 +00:00
|
|
|
|
2021-12-01 07:56:50 +00:00
|
|
|
export function login(userName, passwordHash, session) {
|
2019-11-14 13:37:41 +00:00
|
|
|
const data = {
|
|
|
|
userName,
|
2020-10-16 12:38:04 +00:00
|
|
|
passwordHash,
|
2021-12-01 07:56:50 +00:00
|
|
|
session,
|
2019-11-14 13:37:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return request({
|
|
|
|
method: "post",
|
|
|
|
url: "/authentication.json",
|
2022-03-15 11:33:21 +00:00
|
|
|
skipLogout: true,
|
2020-10-16 12:38:04 +00:00
|
|
|
data,
|
2019-11-14 13:37:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-03-24 13:49:42 +00:00
|
|
|
export function thirdPartyLogin(SerializedProfile) {
|
|
|
|
return request({
|
|
|
|
method: "post",
|
|
|
|
url: "authentication.json",
|
|
|
|
data: { SerializedProfile },
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-11-14 13:37:41 +00:00
|
|
|
export function logout() {
|
|
|
|
return request({
|
|
|
|
method: "post",
|
2020-10-16 12:38:04 +00:00
|
|
|
url: "/authentication/logout",
|
2019-11-14 13:37:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function checkConfirmLink(data) {
|
|
|
|
return request({
|
|
|
|
method: "post",
|
|
|
|
url: "/authentication/confirm.json",
|
2020-10-16 12:38:04 +00:00
|
|
|
data,
|
2019-11-14 13:37:41 +00:00
|
|
|
});
|
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
|
|
|
});
|
|
|
|
}
|
2021-05-17 13:32:22 +00:00
|
|
|
|
|
|
|
export function loginWithTfaCode(userName, passwordHash, code) {
|
|
|
|
const data = {
|
|
|
|
userName,
|
|
|
|
passwordHash,
|
|
|
|
code,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request({
|
|
|
|
method: "post",
|
|
|
|
url: `/authentication/${code}`,
|
2022-03-31 19:34:32 +00:00
|
|
|
skipLogout: true,
|
2021-05-17 13:32:22 +00:00
|
|
|
data,
|
|
|
|
});
|
|
|
|
}
|