This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* xeslint-disable */
|
||||
import decode from "jwt-decode";
|
||||
import logger from "./logit";
|
||||
import store from "../store";
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user