Skip to content

Commit ad62677

Browse files
committed
http requests carry info if access token is required
1 parent 1f6dd30 commit ad62677

File tree

15 files changed

+70
-70
lines changed

15 files changed

+70
-70
lines changed

frontend/src/components/app/matches/Chat.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ export default {
101101
const response = await this.$http.post('/messages/send', {
102102
to_uid: this.user.id.toString(),
103103
content: this.message,
104-
});
104+
}, { accessTokenRequired: true });
105105
this.messages.push(response.data.new_message);
106106
this.message = '';
107107
this.$emit('new-message');
108108
this.scrollChatToBottom();
109109
},
110110
async fetchNewMessages() {
111-
await this.$http.post(`/messages/see/${this.chatWithUserId}`);
112-
const messagesRequest = await this.$http.get(`/conversations/${this.chatWithUserId}`);
111+
await this.$http.post(`/messages/see/${this.chatWithUserId}`, null, { accessTokenRequired: true });
112+
const messagesRequest = await this.$http.get(`/conversations/${this.chatWithUserId}`, { accessTokenRequired: true });
113113
const newMessages = messagesRequest.data.messages;
114114
const oldMessageCount = this.messages.length;
115115
this.messages = newMessages;
@@ -121,11 +121,11 @@ export default {
121121
}
122122
},
123123
async prepareChatForNewUser() {
124-
await this.$http.post(`/messages/see/${this.chatWithUserId}`);
125-
const messagesRequest = await this.$http.get(`/conversations/${this.chatWithUserId}`);
124+
await this.$http.post(`/messages/see/${this.chatWithUserId}`, null, { accessTokenRequired: true });
125+
const messagesRequest = await this.$http.get(`/conversations/${this.chatWithUserId}`, { accessTokenRequired: true });
126126
this.messages = messagesRequest.data.messages;
127127
this.determineFirstMessagesOfTimespans(this.messages);
128-
const userRequest = await this.$http.get(`/users/${this.chatWithUserId}`);
128+
const userRequest = await this.$http.get(`/users/${this.chatWithUserId}`, { accessTokenRequired: true });
129129
this.user = userRequest.data;
130130
this.scrollChatToBottom();
131131
},

frontend/src/components/app/matches/MessageBubble.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ export default {
5656
}
5757
if (!isLiked) {
5858
this.message.is_liked = true;
59-
await this.$http.post(`/messages/like/${id}`);
59+
await this.$http.post(`/messages/like/${id}`, null, { accessTokenRequired: true });
6060
} else {
6161
this.message.is_liked = false;
62-
await this.$http.post(`/messages/unlike/${id}`);
62+
await this.$http.post(`/messages/unlike/${id}`, null, { accessTokenRequired: true });
6363
}
6464
},
6565
},

frontend/src/components/app/onboarding/Location.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default {
5151
this.$emit('next-slide');
5252
},
5353
async sendLocation() {
54-
await this.$http.put('/profile/edit/geolocation', this.locationData);
54+
await this.$http.put('/profile/edit/geolocation', this.locationData, { accessTokenRequired: true });
5555
},
5656
},
5757
mounted() {

frontend/src/components/app/onboarding/MainAndSecondaryImagesUpload.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export default {
5252
const formData = new FormData();
5353
formData.append('file[]', this.imagesUploaded[i].content);
5454
if (i === 0) {
55-
await this.$http.post('/profile/images?is_primary=true', formData);
55+
await this.$http.post('/profile/images?is_primary=true', formData, { accessTokenRequired: true });
5656
} else {
57-
await this.$http.post('/profile/images?is_primary=false', formData);
57+
await this.$http.post('/profile/images?is_primary=false', formData, { accessTokenRequired: true });
5858
}
5959
} catch (error) {}
6060
}

frontend/src/components/app/settings/AccountInput.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,25 @@ export default {
8585
this.currentValueBackup = this.currentValue;
8686
try {
8787
if (this.type === 'firstName') {
88-
await this.$http.patch('/profile/edit/first_name', { first_name: this.currentValue });
88+
await this.$http.patch('/profile/edit/first_name', { first_name: this.currentValue }, { accessTokenRequired: true });
8989
} else if (this.type === 'lastName') {
90-
await this.$http.patch('/profile/edit/last_name', { last_name: this.currentValue });
90+
await this.$http.patch('/profile/edit/last_name', { last_name: this.currentValue }, { accessTokenRequired: true });
9191
} else if (this.type === 'email') {
92-
await this.$http.put('/profile/edit/email', { email: this.currentValue });
92+
await this.$http.put('/profile/edit/email', { email: this.currentValue }, { accessTokenRequired: true });
9393
} else if (this.type === 'username') {
94-
await this.$http.patch('/profile/edit/username', { username: this.currentValue });
94+
await this.$http.patch('/profile/edit/username', { username: this.currentValue }, { accessTokenRequired: true });
9595
} else if (this.type === 'bio') {
96-
await this.$http.patch('/profile/edit/bio', { bio: this.currentValue });
96+
await this.$http.patch('/profile/edit/bio', { bio: this.currentValue }, { accessTokenRequired: true });
9797
} else if (this.type === 'password') {
9898
await this.$http.put('/profile/edit/password', {
9999
old_password: this.passwordOld,
100100
new_password: this.currentValue,
101-
});
101+
}, { accessTokenRequired: true });
102102
this.currentValue = '';
103103
this.passwordRepeat = '';
104104
this.passwordOld = '';
105105
}
106-
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`);
106+
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`, { accessTokenRequired: true });
107107
await this.$store.dispatch('login', user.data);
108108
} catch (error) {
109109
this.error = error.response.data.error.message;

frontend/src/components/app/users/User.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export default {
3838
},
3939
watch: {
4040
async $route() {
41-
const userRequest = await this.$http.get(`/profile/view/${this.$route.params.id}`);
41+
const userRequest = await this.$http.get(`/profile/view/${this.$route.params.id}`, { accessTokenRequired: true });
4242
this.user = userRequest.data.profile;
4343
},
4444
},
4545
async beforeMount() {
4646
try {
47-
const userRequest = await this.$http.get(`/profile/view/${this.$route.params.id}`);
47+
const userRequest = await this.$http.get(`/profile/view/${this.$route.params.id}`, { accessTokenRequired: true });
4848
this.user = userRequest.data.profile;
4949
} catch (error) {
5050
this.error = error.response.data.error.message;

frontend/src/components/app/users/UserProfile.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,26 @@ export default {
166166
async buttonClicked(...args) {
167167
const [name] = args;
168168
if (name === 'like') {
169-
await this.$http.post(`/like/${this.user.id}`, { is_superlike: false });
169+
await this.$http.post(`/like/${this.user.id}`, { is_superlike: false }, { accessTokenRequired: true });
170170
this.likeButtons.likeClicked = true;
171171
} else if (name === 'superLike') {
172-
await this.$http.post(`/like/${this.user.id}`, { is_superlike: true });
172+
await this.$http.post(`/like/${this.user.id}`, { is_superlike: true }, { accessTokenRequired: true });
173173
this.likeButtons.superLikeClicked = true;
174174
}
175-
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`);
175+
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`, { accessTokenRequired: true });
176176
await this.$store.dispatch('login', user.data);
177177
this.checkIfUserIsMatched();
178178
},
179179
async buttonRevert(...args) {
180180
const [name] = args;
181181
if (name === 'like') {
182-
await this.$http.post(`/unlike/${this.user.id}`, { is_superlike: false });
182+
await this.$http.post(`/unlike/${this.user.id}`, { is_superlike: false }, { accessTokenRequired: true });
183183
this.likeButtons.likeClicked = false;
184184
} else if (name === 'superLike') {
185-
await this.$http.post(`/unlike/${this.user.id}`, { is_superlike: true });
185+
await this.$http.post(`/unlike/${this.user.id}`, { is_superlike: true }, { accessTokenRequired: true });
186186
this.likeButtons.superLikeClicked = false;
187187
}
188-
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`);
188+
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`, { accessTokenRequired: true });
189189
await this.$store.dispatch('login', user.data);
190190
this.checkIfUserIsMatched();
191191
},
@@ -196,22 +196,22 @@ export default {
196196
}
197197
},
198198
async makeReport() {
199-
await this.$http.post(`/profile/report/${this.user.id}`, { reason: this.report });
199+
await this.$http.post(`/profile/report/${this.user.id}`, { reason: this.report }, { accessTokenRequired: true });
200200
this.reported = true;
201201
setTimeout(() => {
202202
this.reported = false;
203203
}, 3000);
204204
},
205205
async block() {
206-
await this.$http.post(`/profile/block/${this.user.id}`);
206+
await this.$http.post(`/profile/block/${this.user.id}`, null, { accessTokenRequired: true });
207207
this.blocked = true;
208-
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`);
208+
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`, { accessTokenRequired: true });
209209
await this.$store.dispatch('login', user.data);
210210
},
211211
async unblock() {
212-
await this.$http.post(`/profile/unblock/${this.user.id}`);
212+
await this.$http.post(`/profile/unblock/${this.user.id}`, null, { accessTokenRequired: true });
213213
this.blocked = false;
214-
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`);
214+
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`, { accessTokenRequired: true });
215215
await this.$store.dispatch('login', user.data);
216216
},
217217
checkIfUserIsLiked() {
@@ -270,7 +270,7 @@ export default {
270270
}
271271
},
272272
async mounted() {
273-
const sliderRangesRequest = await this.$http.get('/search/values');
273+
const sliderRangesRequest = await this.$http.get('/search/values', { accessTokenRequired: true });
274274
const maxScore = sliderRangesRequest.data.search_minmax.max_score;
275275
const sliderScore = document.getElementById('sliderScore');
276276
if (sliderScore) {

frontend/src/components/shared/NavBarBell.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default {
8787
const length = this.notifications.length;
8888
for (let i = 0; i < length; i += 1) {
8989
if (!this.notifications[i].is_seen) {
90-
await this.$http.post(`/notifications/read/${this.notifications[i].id}`);
90+
await this.$http.post(`/notifications/read/${this.notifications[i].id}`, null, { accessTokenRequired: true });
9191
this.notifications[i].is_seen = 1;
9292
}
9393
}
@@ -130,19 +130,19 @@ export default {
130130
}
131131
},
132132
async fetchNotifications() {
133-
const notificationsRequest = await this.$http.get('/notifications');
133+
const notificationsRequest = await this.$http.get('/notifications', { accessTokenRequired: true });
134134
this.notifications = notificationsRequest.data.notifications;
135135
this.notifications = this.notifications.reverse();
136136
},
137137
async newNotificationCheck() {
138-
const notificationsRequest = await this.$http.get('/notifications/unread');
138+
const notificationsRequest = await this.$http.get('/notifications/unread', { accessTokenRequired: true });
139139
const { notifications } = notificationsRequest.data;
140140
this.notify = notifications.length;
141141
},
142142
async fetchNewNotifications() {
143-
const newNotificationsRequest = await this.$http.get('/notifications/unread');
143+
const newNotificationsRequest = await this.$http.get('/notifications/unread', { accessTokenRequired: true });
144144
const newNotifications = newNotificationsRequest.data.notifications;
145-
if (!newNotifications.length) {
145+
if (!newNotifications || !newNotifications.length) {
146146
return;
147147
}
148148
await this.fetchNotifications();

frontend/src/views/app/Browse.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default {
5858
this.recommendations = this.recommendationsFromSettingUp;
5959
this.firstTimeBrowsing = false;
6060
} else {
61-
const recommendationsRequest = await this.$http.get('/recommendations');
61+
const recommendationsRequest = await this.$http.get('/recommendations', { accessTokenRequired: true });
6262
this.recommendations = recommendationsRequest.data.recommendations;
6363
}
6464
this.recommendations.sort((a, b) => a.distance - b.distance);

frontend/src/views/app/History.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ export default {
7272
methods: {
7373
async fetchUsers(request) {
7474
if (request === 'People I viewed') {
75-
const recommendationsRequest = await this.$http.get('/history/viewed');
75+
const recommendationsRequest = await this.$http.get('/history/viewed', { accessTokenRequired: true });
7676
this.recommendations = recommendationsRequest.data.viewed;
7777
} else if (request === 'People I liked') {
78-
const recommendationsRequest = await this.$http.get('/history/liked');
78+
const recommendationsRequest = await this.$http.get('/history/liked', { accessTokenRequired: true });
7979
this.recommendations = recommendationsRequest.data.liked;
8080
} else if (request === 'Who viewed me') {
81-
const recommendationsRequest = await this.$http.get('/history/viewed/me');
81+
const recommendationsRequest = await this.$http.get('/history/viewed/me', { accessTokenRequired: true });
8282
this.recommendations = recommendationsRequest.data.viewed_me;
8383
} else if (request === 'Who liked me') {
84-
const recommendationsRequest = await this.$http.get('/history/liked/me');
84+
const recommendationsRequest = await this.$http.get('/history/liked/me', { accessTokenRequired: true });
8585
this.recommendations = recommendationsRequest.data.liked_me;
8686
} else if (request === 'Whom I blocked') {
87-
const recommendationsRequest = await this.$http.get('/history/blocked');
87+
const recommendationsRequest = await this.$http.get('/history/blocked', { accessTokenRequired: true });
8888
this.recommendations = recommendationsRequest.data.blocked;
8989
}
9090
this.recommendations = Object.values(this.recommendations.reduce((acc, cur) => Object.assign(acc, { [cur.id]: cur }), {}));

0 commit comments

Comments
 (0)