Fixed Authorization when not reloading the page after logging in
the build failed Details

This commit is contained in:
konrad 2018-01-09 12:11:09 +01:00 committed by kolaente
parent 491f564115
commit 5bf2e4ea70
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
9 changed files with 13 additions and 16 deletions

View File

@ -183,7 +183,7 @@ export default {
this.$on('delete-submit', function () { this.$on('delete-submit', function () {
// Prevent deleting already deleted authors // Prevent deleting already deleted authors
if (obj) { if (obj) {
HTTP.delete('authors/' + obj.id.content) HTTP.delete('authors/' + obj.id.content, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
if (response.status === 200 && response.data.message === 'success') { if (response.status === 200 && response.data.message === 'success') {
// Fire a notification // Fire a notification

View File

@ -98,7 +98,7 @@
// Finally Send it // Finally Send it
// If we want to newly insert it, make a different request // If we want to newly insert it, make a different request
if (this.edit) { if (this.edit) {
HTTP.post('authors/' + this.author.id, this.author) HTTP.post('authors/' + this.author.id, this.author, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false
@ -117,7 +117,7 @@
this.errorNotification(e) this.errorNotification(e)
}) })
} else { // insert a new author } else { // insert a new author
HTTP.put('authors', this.author) HTTP.put('authors', this.author, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false

View File

@ -237,7 +237,7 @@ export default {
this.$on('delete-submit', function () { this.$on('delete-submit', function () {
// Prevent deleting already deleted books // Prevent deleting already deleted books
if (obj) { if (obj) {
HTTP.delete('books/' + obj.id.content) HTTP.delete('books/' + obj.id.content, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
if (response.status === 200 && response.data.message === 'success') { if (response.status === 200 && response.data.message === 'success') {
// Fire a notification // Fire a notification

View File

@ -288,7 +288,7 @@
// Finally Send it // Finally Send it
// If we want to newly insert it, make a different request // If we want to newly insert it, make a different request
if (this.edit) { if (this.edit) {
HTTP.post('books/' + this.book.id, this.book) HTTP.post('books/' + this.book.id, this.book, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false
@ -307,7 +307,7 @@
this.errorNotification(e) this.errorNotification(e)
}) })
} else { // insert a new book } else { // insert a new book
HTTP.put('books', this.book) HTTP.put('books', this.book, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false
// Fire a notification // Fire a notification

View File

@ -190,7 +190,7 @@ export default {
this.$on('delete-submit', function () { this.$on('delete-submit', function () {
// Prevent deleting already deleted item // Prevent deleting already deleted item
if (obj) { if (obj) {
HTTP.delete('items/' + obj.id.content) HTTP.delete('items/' + obj.id.content, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
if (response.status === 200 && response.data.message === 'success') { if (response.status === 200 && response.data.message === 'success') {
// Fire a notification // Fire a notification

View File

@ -109,7 +109,7 @@
// Finally Send it // Finally Send it
// If we want to newly insert it, make a different request // If we want to newly insert it, make a different request
if (this.edit) { if (this.edit) {
HTTP.post('items/' + this.item.id, this.item) HTTP.post('items/' + this.item.id, this.item, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false
@ -128,7 +128,7 @@
this.errorNotification(e) this.errorNotification(e)
}) })
} else { // insert a new item } else { // insert a new item
HTTP.put('items', this.item) HTTP.put('items', this.item, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false

View File

@ -182,7 +182,7 @@ export default {
this.$on('delete-submit', function () { this.$on('delete-submit', function () {
// Prevent again deleting already deleted publishers // Prevent again deleting already deleted publishers
if (obj) { if (obj) {
HTTP.delete('publishers/' + obj.id.content) HTTP.delete('publishers/' + obj.id.content, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
if (response.status === 200 && response.data.message === 'success') { if (response.status === 200 && response.data.message === 'success') {
// Fire a notification // Fire a notification

View File

@ -89,7 +89,7 @@
// Finally Send it // Finally Send it
// If we want to newly insert it, make a different request // If we want to newly insert it, make a different request
if (this.edit) { if (this.edit) {
HTTP.post('publishers/' + this.publisher.id, this.publisher) HTTP.post('publishers/' + this.publisher.id, this.publisher, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false
@ -108,7 +108,7 @@
this.errorNotification(e) this.errorNotification(e)
}) })
} else { // insert a new publisher } else { // insert a new publisher
HTTP.put('publishers', this.publisher) HTTP.put('publishers', this.publisher, { headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} })
.then(response => { .then(response => {
this.loading = false this.loading = false

View File

@ -2,8 +2,5 @@ import axios from 'axios'
let config = require('../../siteconfig.json') let config = require('../../siteconfig.json')
export const HTTP = axios.create({ export const HTTP = axios.create({
baseURL: config.API_URL, baseURL: config.API_URL
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('token')
}
}) })