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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user