diff --git a/src/app/components/home/home-page/home-page.component.spec.ts b/src/app/components/home/home-page/home-page.component.spec.ts index efc51134181a7eac400311a2360239645cb094fd..ffdebfc19f62e09c8921210cafd00929e4565e1a 100644 --- a/src/app/components/home/home-page/home-page.component.spec.ts +++ b/src/app/components/home/home-page/home-page.component.spec.ts @@ -7,6 +7,7 @@ import { NewLandingComponent } from '../new-landing/new-landing.component'; import { SharedModule } from '../../shared/shared.module'; import { AppRoutingModule } from '../../../app-routing.module'; import { AuthenticationService } from '../../../services/http/authentication.service'; +import { ModeratorService } from '../../../services/http/moderator.service'; import { DataStoreService } from '../../../services/util/data-store.service'; import { NotificationService } from '../../../services/util/notification.service'; import { RoomService } from '../../../services/http/room.service'; @@ -23,17 +24,22 @@ describe('HomePageComponent', () => { declarations: [ HomePageComponent, NewLandingComponent, UserHomeComponent ], - imports: [ EssentialsModule, - SharedModule, - AppRoutingModule, - BrowserAnimationsModule ], - providers: [ LanguageService, - AuthenticationService, - DataStoreService, - NotificationService, - LanguageService, - EventService, - RoomService ] + imports: [ + EssentialsModule, + SharedModule, + AppRoutingModule, + BrowserAnimationsModule + ], + providers: [ + LanguageService, + AuthenticationService, + DataStoreService, + NotificationService, + LanguageService, + EventService, + ModeratorService, + RoomService + ] }) .compileComponents(); })); diff --git a/src/app/components/shared/room-join/room-join.component.ts b/src/app/components/shared/room-join/room-join.component.ts index 302f4ed945c242b1ce7e5441da210da054cc6a8c..44fbb5e11644026f7ac130026244e5472ddfe2a7 100644 --- a/src/app/components/shared/room-join/room-join.component.ts +++ b/src/app/components/shared/room-join/room-join.component.ts @@ -9,6 +9,8 @@ import { TranslateService } from '@ngx-translate/core'; import { AuthenticationService } from '../../../services/http/authentication.service'; import { UserRole } from '../../../models/user-roles.enum'; import { User } from '../../../models/user'; +import { Moderator } from '../../../models/moderator'; +import { ModeratorService } from '../../../services/http/moderator.service'; @Component({ selector: 'app-room-join', @@ -30,7 +32,8 @@ export class RoomJoinComponent implements OnInit { private router: Router, public notificationService: NotificationService, private translateService: TranslateService, - public authenticationService: AuthenticationService + public authenticationService: AuthenticationService, + private moderatorService: ModeratorService ) { } @@ -95,9 +98,20 @@ export class RoomJoinComponent implements OnInit { this.router.navigate([`/creator/room/${this.room.shortId}/comments`]); } else { this.roomService.addToHistory(this.room.id); - this.authenticationService.setAccess(this.room.shortId, UserRole.PARTICIPANT); - - this.router.navigate([`/participant/room/${this.room.shortId}/comments`]); + this.moderatorService.get(this.room.id).subscribe((moderators: Moderator[]) => { + let isModerator = false; + for (const m of moderators) { + if (m.userId === this.user.id) { + this.authenticationService.setAccess(this.room.shortId, UserRole.EXECUTIVE_MODERATOR); + this.router.navigate([`/moderator/room/${this.room.shortId}/comments`]); + isModerator = true; + } + } + if (!isModerator) { + this.authenticationService.setAccess(this.room.shortId, UserRole.PARTICIPANT); + this.router.navigate([`/participant/room/${this.room.shortId}/comments`]); + } + }); } } }