2020-12-04 08:38:15 +00:00
|
|
|
import { request, setWithCredentialsStatus } from "../client";
|
2019-11-14 13:37:41 +00:00
|
|
|
|
2020-09-30 21:44:49 +00:00
|
|
|
export function login(userName, passwordHash) {
|
2019-11-14 13:37:41 +00:00
|
|
|
const data = {
|
|
|
|
userName,
|
2020-10-16 12:38:04 +00:00
|
|
|
passwordHash,
|
2019-11-14 13:37:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return request({
|
|
|
|
method: "post",
|
|
|
|
url: "/authentication.json",
|
2020-10-16 12:38:04 +00:00
|
|
|
data,
|
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
|
|
|
});
|
|
|
|
}
|