all over the place with comments and console statements but now properly chains all the calls for login (except translation may have an issue)

This commit is contained in:
2020-06-10 21:05:45 +00:00
parent c0fcecb3f8
commit 0a43e53ab7
25 changed files with 1966 additions and 976 deletions

View File

@@ -4,24 +4,61 @@ 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.extractBody)
.then(processLogin)
.then(() => {
return Promise.resolve(true);
}) //succeeded, nothing to return
.catch(function handleAuthError(error) {
processLogout();
return Promise.reject(error);
});
return new Promise(async function doAuth(resolve, reject) {
try {
console.log("AUTH: TOP");
let fetchData = await fetch(
window.$gz.api.APIUrl("auth"),
window.$gz.api.fetchPostNoAuthOptions({
login: login,
password: password
})
);
console.log("AUTH: status");
fetchData = await window.$gz.api.status(fetchData);
console.log("AUTH: extractBody");
fetchData = await window.$gz.api.extractBody(fetchData);
console.log("AUTH: calling processLogin");
await processLogin(fetchData);
console.log(
"### AUTH:after processlogin completed - resolving done (THIS SHOULD BE LAST)"
);
resolve();
} catch (e) {
reject(e);
}
// .catch(function handleAuthError(error) {
// processLogout();
// return reject(error);
// });
// .then(processLogin)
// .then(() => {
// return resolve(true);
// }) //succeeded, nothing to return
});
},
// 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.extractBody)
// .then(processLogin)
// .then(() => {
// console.log("auth:authenticate returning resolved done");
// return Promise.resolve(true);
// }) //succeeded, nothing to return
// .catch(function handleAuthError(error) {
// processLogout();
// return Promise.reject(error);
// });
// },
logout() {
processLogout();
}