diff --git a/app/ayanova/src/api/apiutil.js b/app/ayanova/src/api/apiutil.js index c4c24549..dc2d720f 100644 --- a/app/ayanova/src/api/apiutil.js +++ b/app/ayanova/src/api/apiutil.js @@ -1,3 +1,4 @@ +/* xeslint-disable */ import logger from "../utils/logit"; import store from "../store"; @@ -13,13 +14,35 @@ export default { json(response) { return response.json(); }, - AuthorizedHeaders() { + PatchAuthorizedHeaders() { return { - Accept: "application/json, text/plain, */*", + //Accept: "application/json, text/plain, */*", + Accept: "application/json", + "Content-Type": "application/json-patch+json", + Authorization: "Bearer " + store.state.apiToken + }; + }, + PostAuthorizedHeaders() { + return { + Accept: "application/json", "Content-Type": "application/json", Authorization: "Bearer " + store.state.apiToken }; }, + PostUnAuthorizedHeaders() { + return { + Accept: "application/json", + "Content-Type": "application/json" + }; + }, + fetchPostNoAuth(data) { + return { + method: "post", + mode: "cors", + headers: this.PostUnAuthorizedHeaders(), + body: JSON.stringify(data) + }; + }, APIUrl() { return store.state.apiUrl; } diff --git a/app/ayanova/src/api/auth.js b/app/ayanova/src/api/auth.js index 12fc4843..72941fc3 100644 --- a/app/ayanova/src/api/auth.js +++ b/app/ayanova/src/api/auth.js @@ -1,20 +1,16 @@ +/* xeslint-disable */ import apiUtil from "./apiutil"; import { processLogin, processLogout } from "../utils/authutil"; export default { async authenticate(login, password) { - return fetch(apiUtil.APIUrl + "auth", { - method: "post", - mode: "cors", - headers: { - Accept: "application/json, text/plain, */*", - "Content-Type": "application/json" - }, - body: JSON.stringify({ + return fetch( + apiUtil.APIUrl() + "auth", + apiUtil.fetchPostNoAuth({ login: login, password: password }) - }) + ) .then(apiUtil.status) .then(apiUtil.json) .then(processLogin) diff --git a/app/ayanova/src/api/locale.js b/app/ayanova/src/api/locale.js index f23a9dc4..ea339a50 100644 --- a/app/ayanova/src/api/locale.js +++ b/app/ayanova/src/api/locale.js @@ -23,10 +23,11 @@ export default { resolve(); return; } - fetch(apiUtil.APIUrl + "locale/subset", { + //step 2: get it + fetch(apiUtil.APIUrl() + "locale/subset", { method: "post", mode: "cors", - headers: apiUtil.AuthorizedHeaders(), + headers: apiUtil.PostAuthorizedHeaders(), body: JSON.stringify(NeedIt) }) .then(apiUtil.status) diff --git a/app/ayanova/src/utils/authutil.js b/app/ayanova/src/utils/authutil.js index 78164535..dfd2b9a0 100644 --- a/app/ayanova/src/utils/authutil.js +++ b/app/ayanova/src/utils/authutil.js @@ -1,3 +1,4 @@ +/* xeslint-disable */ import decode from "jwt-decode"; import logger from "./logit"; import store from "../store"; diff --git a/app/ayanova/src/views/login.vue b/app/ayanova/src/views/login.vue index 84262178..faa0d97c 100644 --- a/app/ayanova/src/views/login.vue +++ b/app/ayanova/src/views/login.vue @@ -59,6 +59,8 @@ export default { this.$router.replace({ name: "home" }); }) .catch(function(error) { + /* eslint-disable-next-line */ + console.log(error); alert("login failed: " + error); }); }