Commit d4219005 authored by Andrea Ida Malkah Klaura's avatar Andrea Ida Malkah Klaura
Browse files

added OIDC access_token to all put and post requests

still TODO regarding OIDC:
* handle token expiration and refreshing

still TODO regarding ShowManager:
* finalize all requests for ShowManagerModal*
* change getting notes: we now have a note_id in every timeslot
* handle repetitions when updateing timeslots & notes
* creation of new timeslots and collision handling
parent c6e0b9f0
......@@ -363,7 +363,10 @@ export default {
if (typeof end === 'object') uri += '&end=' + this.apiDate(end)
if (typeof limit === 'number') uri += '&limit=' + limit
if (typeof offset === 'number') uri += '&offset=' + offset
axios.get(uri, {withCredentials: true}).then(response => {
axios.get(uri, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
// if we use the limit argument results are paginated and look different
// than without the limit argument
if (typeof limit === 'number') {
......@@ -384,7 +387,10 @@ export default {
// timeslots that are also visible to the user
// TODO: discuss: when a timeslot can only have one not, why is the id
// of this note not stored in the timeslot? would be way more efficient
axios.get(process.env.API_STEERING_SHOWS + this.currentShowID + '/notes/', {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING_SHOWS + this.currentShowID + '/notes/', {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.notes = response.data
this.loaded.notes = true
}).catch(error => {
......@@ -445,7 +451,10 @@ export default {
this.loaded.categories = true
} else {
for (var i in this.shows[this.currentShow].category) {
axios.get(process.env.API_STEERING + 'categories/' + this.shows[this.currentShow].category[i], {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING + 'categories/' + this.shows[this.currentShow].category[i], {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.current.categories.push(response.data)
}).catch(error => {
loadingError = true
......@@ -462,7 +471,10 @@ export default {
this.loaded.hosts = true
} else {
for (var i in this.shows[this.currentShow].hosts) {
axios.get(process.env.API_STEERING + 'hosts/' + this.shows[this.currentShow].hosts[i] + '/', {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING + 'hosts/' + this.shows[this.currentShow].hosts[i] + '/', {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.current.hosts.push(response.data)
}).catch(error => {
loadingError = true
......@@ -479,7 +491,10 @@ export default {
this.loaded.languages = true
} else {
for (var i in this.shows[this.currentShow].language) {
axios.get(process.env.API_STEERING + 'languages/' + this.shows[this.currentShow].language[i], {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING + 'languages/' + this.shows[this.currentShow].language[i], {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.current.languages.push(response.data)
}).catch(error => {
loadingError = true
......@@ -496,7 +511,10 @@ export default {
this.loaded.topics = true
} else {
for (var i in this.shows[this.currentShow].topic) {
axios.get(process.env.API_STEERING + 'topics/' + this.shows[this.currentShow].topic[i], {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING + 'topics/' + this.shows[this.currentShow].topic[i], {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.current.topics.push(response.data)
}).catch(error => {
loadingError = true
......@@ -513,7 +531,10 @@ export default {
this.loaded.musicfocus = true
} else {
for (var i in this.shows[this.currentShow].musicfocus) {
axios.get(process.env.API_STEERING + 'musicfocus/' + this.shows[this.currentShow].musicfocus[i], {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING + 'musicfocus/' + this.shows[this.currentShow].musicfocus[i], {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.current.musicfocus.push(response.data)
}).catch(error => {
loadingError = true
......@@ -529,7 +550,10 @@ export default {
if (typeof this.shows[this.currentShow].rtrcategory !== 'number') {
this.loaded.rtrcategory = true
} else {
axios.get(process.env.API_STEERING + 'rtrcategories/' + this.shows[this.currentShow].rtrcategory, {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING + 'rtrcategories/' + this.shows[this.currentShow].rtrcategory, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.current.rtrcategory.push(response.data)
}).catch(error => {
loadingError = true
......@@ -544,7 +568,10 @@ export default {
if (typeof this.shows[this.currentShow].type !== 'number') {
this.loaded.type = true
} else {
axios.get(process.env.API_STEERING + 'types/' + this.shows[this.currentShow].type, {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING + 'types/' + this.shows[this.currentShow].type, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.current.type.push(response.data)
}).catch(error => {
loadingError = true
......@@ -558,7 +585,11 @@ export default {
}
},
created () {
axios.get(process.env.API_STEERING_SHOWS, {withCredentials: true}).then(response => {
axios.get(process.env.API_STEERING_SHOWS, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
console.log(response.data[0])
this.shows = response.data
this.currentShowID = this.shows[0].id
this.currentShow = 0
......
......@@ -78,6 +78,7 @@ export default {
// now send the PUT request with our updated note
axios.put(uri, this.note, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.$parent.user.access_token },
transformResponse: [debugErrorResponse]
}).then(response => {
console.log('Response:')
......@@ -135,6 +136,7 @@ export default {
// now send the POST request with our updated note
axios.post(uri, this.note, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.$parent.user.access_token },
transformResponse: [debugErrorResponse]
}).then(response => {
console.log('Response:')
......
......@@ -64,6 +64,7 @@ export default {
console.log(this.show)
axios.put(process.env.API_STEERING_SHOWS + this.show.id + '/', this.show, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.$parent.user.access_token },
transformResponse: [debugErrorResponse]
}).then(response => {
console.log('Response:')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment