Fixed login/logout issue
This commit is contained in:
@@ -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()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user