29 lines
662 B
JavaScript
29 lines
662 B
JavaScript
/* Xeslint-disable */
|
|
|
|
import { processLogin, processLogout } from "./authutil";
|
|
|
|
export default {
|
|
async authenticate(login, password) {
|
|
return fetch(
|
|
window.$gz.api.APIUrl("auth"),
|
|
window.$gz.api.fetchPostNoAuthOptions({
|
|
login: login,
|
|
password: password
|
|
})
|
|
)
|
|
.then(window.$gz.api.status)
|
|
.then(window.$gz.api.json)
|
|
.then(processLogin)
|
|
.then(() => {
|
|
return Promise.resolve(true);
|
|
}) //succeeded, nothing to return
|
|
.catch(function handleAuthError(error) {
|
|
processLogout();
|
|
return Promise.reject(error);
|
|
});
|
|
},
|
|
logout() {
|
|
processLogout();
|
|
}
|
|
};
|