Skip to content

Commit 6783c0c

Browse files
committed
Add auth to fetch
1 parent 0cf234f commit 6783c0c

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

frontend/src/app/shared/services/open-vidu.service.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ export class OpenViduService {
3838
}
3939

4040
syncRemoveUser(roomName: string) {
41-
fetch(this.baseURL + '/room/' + roomName + '/user', {
42-
method: 'DELETE',
43-
keepalive: true
44-
});
41+
if(this.userSrv.isLogged && !!roomName) {
42+
let headers = new Headers();
43+
headers.set('Authorization', `Basic ${this.userSrv.user.authdata}`);
44+
fetch(this.baseURL + '/room/' + roomName + '/user', {
45+
method: 'DELETE',
46+
headers: headers,
47+
keepalive: true
48+
});
49+
}
4550
}
4651

4752
getToken(mySessionId: string): Promise<string> {

frontend/src/app/shared/services/room.service.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,21 @@ export class RoomService {
8484
}
8585

8686
syncLowerHand(roomName: string, connectionId: string) {
87-
let body = {
88-
"connectionId": connectionId
89-
};
90-
fetch(this.baseURL + '/room/' + roomName + '/raiseHand', {
91-
method: 'DELETE',
92-
body: JSON.stringify(body),
93-
keepalive: true
94-
});
87+
if (this.userService.isLogged && !!roomName) {
88+
let body = {
89+
connectionId: connectionId
90+
};
91+
let headers = new Headers();
92+
headers.set('Authorization', `Basic ${this.userService.user.authdata}`);
93+
headers.set('Accept', 'application/json');
94+
headers.set('Content-Type', 'application/json');
95+
fetch(this.baseURL + '/room/' + roomName + '/raiseHand', {
96+
method: 'DELETE',
97+
body: JSON.stringify(body),
98+
headers: headers,
99+
keepalive: true
100+
});
101+
}
95102
}
96103

97104
private handleError(error: any) {

0 commit comments

Comments
 (0)