Fixed login/logout issue

This commit is contained in:
2017-10-25 15:35:56 +07:00
parent 5e73adada1
commit 0c56440363
8 changed files with 123 additions and 96 deletions

View File

@@ -1,6 +1,7 @@
let m = require('mithril')
let _ = require('lodash')
let post = require('./post')
let user = require('./user')
var category = {
loading: false,
@@ -36,14 +37,16 @@ var category = {
method: 'PUT',
url: '/api/kategori',
data: category.current,
withCredentials: true
withCredentials: true,
headers: {'x-query': window.location.search}
})
.then(function(result) {
console.log(result)
category.current = {}
if (result.status) {
if (result.status == true) {
m.route.set('/kategori')
} else {
console.log(result)
} else if (result.status == 401) {
user.logout();
}
})
},
@@ -52,13 +55,15 @@ var category = {
method: 'POST',
url: '/api/kategori',
data: category.current,
withCredentials: true
withCredentials: true,
headers: {'x-query': window.location.search}
})
.then(function(result) {
if (result.status) {
console.log(result);
if (result.status == true) {
category.loadList()
} else {
console.log(result.status)
} else if (result.status == 401) {
user.logout()
}
})
},

View File

@@ -38,7 +38,7 @@ var user = {
url: '/post',
data: user.current,
withCredentials: true,
headers: {client: 'api'}
headers: {client: 'api', 'x-query': window.location.search}
})
.then(function(response) {
if (response.status == true) {