From be76e4653079a144a04054fd1a14c4f817c32228 Mon Sep 17 00:00:00 2001 From: Ruben Bimberg <ruben.bimberg@mni.thm.de> Date: Thu, 24 Jun 2021 00:27:11 +0200 Subject: [PATCH] Fix UserRole bug This commit fixes the UserRole error. After a user enters a room, another check is performed to ensure his role. [Ticket: #118] --- .../topic-cloud-filter.component.ts | 6 +- .../comment-list/comment-list.component.ts | 1 + .../shared/header/header.component.ts | 2 +- .../shared/room-join/room-join.component.ts | 2 +- .../shared/tag-cloud/tag-cloud.component.ts | 1 + src/assets/i18n/creator/de.json | 53 ++++++++++++++++++ src/assets/i18n/creator/en.json | 55 ++++++++++++++++++- 7 files changed, 114 insertions(+), 6 deletions(-) diff --git a/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts b/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts index f86b23334..a26ac48fa 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts +++ b/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts @@ -5,7 +5,7 @@ import { TranslateService } from '@ngx-translate/core'; import { RoomCreatorPageComponent } from '../../../creator/room-creator-page/room-creator-page.component'; import { LanguageService } from '../../../../services/util/language.service'; import { EventService } from '../../../../services/util/event.service'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { CommentFilter } from '../../../../utils/filter-options'; import { RoomService } from '../../../../services/http/room.service'; import { Comment } from '../../../../models/comment'; @@ -23,7 +23,7 @@ class CommentsCount { styleUrls: ['./topic-cloud-filter.component.scss'] }) export class TopicCloudFilterComponent implements OnInit { - @Input() shortId: string; + @Input() target: string; continueFilter = 'continueWithCurr'; comments: Comment[]; @@ -115,7 +115,7 @@ export class TopicCloudFilterComponent implements OnInit { } CommentFilter.currentFilter = filter; - this.dialogRef.close(this.router.navigateByUrl('/participant/room/' + this.shortId + '/comments/tagcloud')); + this.dialogRef.close(this.router.navigateByUrl(this.target)); }; } } diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index df307557e..58675a62c 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -224,6 +224,7 @@ export class CommentListComponent implements OnInit, OnDestroy { this.userRole = this.route.snapshot.data.roles[0]; this.route.params.subscribe(params => { this.shortId = params['shortId']; + this.authenticationService.checkAccess(this.shortId); this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(r => { this.roomService.getRoomByShortId(this.shortId).subscribe(room => { this.room = room; diff --git a/src/app/components/shared/header/header.component.ts b/src/app/components/shared/header/header.component.ts index 41b092c9a..cff27dafb 100644 --- a/src/app/components/shared/header/header.component.ts +++ b/src/app/components/shared/header/header.component.ts @@ -305,7 +305,7 @@ export class HeaderComponent implements OnInit { const confirmDialogRef = this.confirmDialog.open(TopicCloudFilterComponent, { autoFocus: false }); - confirmDialogRef.componentInstance.shortId = this.shortId; + confirmDialogRef.componentInstance.target = this.router.url + '/tagcloud'; } public navigateTopicCloudConfig() { 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 66cf2e77a..6a4cd1748 100644 --- a/src/app/components/shared/room-join/room-join.component.ts +++ b/src/app/components/shared/room-join/room-join.component.ts @@ -74,7 +74,7 @@ export class RoomJoinComponent implements OnInit { joinRoom(id: string): void { if (!this.sessionCodeFormControl.hasError('required') && !this.sessionCodeFormControl.hasError('minlength')) { if (!this.user) { - this.authenticationService.guestLogin(UserRole.CREATOR).subscribe(() => { + this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(() => { this.getRoom(id); }); } else { diff --git a/src/app/components/shared/tag-cloud/tag-cloud.component.ts b/src/app/components/shared/tag-cloud/tag-cloud.component.ts index fed79b451..92b98129d 100644 --- a/src/app/components/shared/tag-cloud/tag-cloud.component.ts +++ b/src/app/components/shared/tag-cloud/tag-cloud.component.ts @@ -252,6 +252,7 @@ export class TagCloudComponent implements OnInit, OnDestroy, AfterContentInit, A this.userRole = this.route.snapshot.data.roles[0]; this.route.params.subscribe(params => { this.shortId = params['shortId']; + this.authenticationService.checkAccess(this.shortId); this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(r => { this.roomService.getRoomByShortId(this.shortId).subscribe(room => { this.room = room; diff --git a/src/assets/i18n/creator/de.json b/src/assets/i18n/creator/de.json index 534f7bcb3..5985384c7 100644 --- a/src/assets/i18n/creator/de.json +++ b/src/assets/i18n/creator/de.json @@ -343,6 +343,59 @@ "session-name": "Name der Sitzung", "preview": "Vorschau" }, + "tag-cloud-popup": { + "few-seconds": "wenige Sekunden", + "few-minutes": "wenige Minuten", + "some-minutes": "{{minutes}} Minuten", + "one-hour": "1 Stunde", + "some-hours": "{{hours}} Stunden", + "one-day": "1 Tag", + "some-days": "{{days}} Tage", + "one-week": "1 Woche", + "some-weeks": "{{weeks}} Wochen", + "some-months": "{{months}} Monate", + "tag-correction-placeholder": "Korrektur" + }, + "topic-cloud-dialog": { + "cancel": "Abbrechen", + "save": "Speichern", + "edit": "Bearbeiten", + "delete": "Löschen", + "question-count-singular": "Frage", + "question-count-plural": "Fragen", + "edit-keyword-tip": "Neues Thema", + "no-keywords-note": "Es gibt keine Themen", + "consider-votes": "Votes berücksichtigen", + "profanity": "Schimpfwörter zensieren", + "hide-blacklist-words": "Blacklist Stichworte verbergen", + "sort-alpha": "Alphabetisch", + "sort-count": "Fragenanzahl", + "sort-vote": "Votes", + "keyword-search": "Stichwort suchen", + "edit-profanity-list": "Zensurliste bearbeiten", + "edit-blacklist-list": "Blackliste bearbeiten", + "add-word": "Wort hinzufügen", + "enter-word": "Wort eingeben", + "settings": "Einstellungen", + "keyword": "Stichwort", + "full-text": "Voller Text", + "both": "Beide", + "select-choice": "Wählen Sie aus", + "show-blacklist": "Zeige Blackliste", + "hide-blacklist": "Verberge Blackliste", + "show-profanity-list": "Zeige Schimpfwortliste", + "hide-profanity-list": "Verberge Schimpfwortliste", + "keyword-delete": "Stichwort gelöscht", + "keyword-edit": "Stichwort umbenannt", + "keywords-merge": "Stichwörter zusammengefügt", + "changes-gone-wrong": "Etwas ist schiefgelaufen", + "english": "Englisch", + "german": "Deutsch", + "select-all": "Alle auswählen", + "keyword-counter": "Anzahl der Themen", + "sort": "Sortieren", + "words-will-be-overwritten": "unanständige Wörter werden mit '***' überschrieben" + }, "tag-cloud-config":{ "general":"Allgemein", "overflow":"Überlauf", diff --git a/src/assets/i18n/creator/en.json b/src/assets/i18n/creator/en.json index da9c73b37..f9292bde9 100644 --- a/src/assets/i18n/creator/en.json +++ b/src/assets/i18n/creator/en.json @@ -344,6 +344,59 @@ "session-name": "Session name", "preview": "Preview" }, + "tag-cloud-popup": { + "few-seconds": "few seconds", + "few-minutes": "few minutes", + "some-minutes": "{{minutes}} minutes", + "one-hour": "1 hour", + "some-hours": "{{hours}} hours", + "one-day": "1 day", + "some-days": "{{days}} days", + "one-week": "1 week", + "some-weeks": "{{weeks}} weeks", + "some-months": "{{months}} months", + "tag-correction-placeholder": "Correction" + }, + "topic-cloud-dialog":{ + "edit": "Edit", + "delete": "Delete", + "cancel": "Cancel", + "save": "Save", + "question-count-singular": "Question", + "question-count-plural": "Questions", + "edit-keyword-tip": "New topic", + "no-keywords-note": "There are no topics!", + "consider-votes": "Consider Votes", + "profanity": "Censor profanity", + "hide-blacklist-words": "Hide blacklist keywords", + "sort-alpha": "Alphabetically", + "sort-count": "Questions count", + "sort-vote": "Votes", + "keyword-search": "Search keyword", + "edit-profanity-list": "Edit profanity list", + "edit-blacklist-list": "Edit blacklist list", + "add-word": "Add Word", + "enter-word": "Enter word", + "settings": "Settings", + "keyword": "Keyword", + "full-text": "Full-text", + "both": "Both", + "select-choice": "Select one", + "show-blacklist": "Show blacklist", + "hide-blacklist": "Hide blacklist", + "show-profanity-list": "Show profanity list", + "hide-profanity-list": "Hide profanity list", + "keyword-delete": "keyword deleted", + "keyword-edit": "keyword renamed", + "keywords-merge": "keywords merged", + "changes-gone-wrong": "somthing has gone wrong", + "english": "English", + "german": "German", + "select-all": "Select all", + "keyword-counter": "Topic count", + "sort": "Sort", + "words-will-be-overwritten": "profane words will be overwritten with '***'" + }, "tag-cloud-config":{ "general":"General", "overflow":"Overflow", @@ -395,7 +448,7 @@ "highestWeight-tooltip": "show x tags with the highest weight", "rotate-weight": "Rotate some entries of this weight class randomly by x degrees", "font":"Font", - "reset-btn": "Reset", + "reset-btn": "Reset", "font-style-bold" : "Bold", "font-style-italic": "Italic", "font-family":"Font Family" -- GitLab