Ensure that if a user doesn't have access to a person, person detail page redirects and informs them.
This commit is contained in:
parent
d522bccf86
commit
634b165318
2 changed files with 11 additions and 2 deletions
|
|
@ -26,7 +26,7 @@ export class PersonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
return this.httpClient.get<Person>(this.baseUrl + `person?name=${name}`);
|
return this.httpClient.get<Person | null>(this.baseUrl + `person?name=${name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRolesForPerson(personId: number) {
|
getRolesForPerson(personId: number) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import {translate, TranslocoDirective} from "@jsverse/transloco";
|
||||||
import {ChapterCardComponent} from "../cards/chapter-card/chapter-card.component";
|
import {ChapterCardComponent} from "../cards/chapter-card/chapter-card.component";
|
||||||
import {ThemeService} from "../_services/theme.service";
|
import {ThemeService} from "../_services/theme.service";
|
||||||
import {DefaultModalOptions} from "../_models/default-modal-options";
|
import {DefaultModalOptions} from "../_models/default-modal-options";
|
||||||
|
import {ToastrService} from "ngx-toastr";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-person-detail',
|
selector: 'app-person-detail',
|
||||||
|
|
@ -74,6 +75,7 @@ export class PersonDetailComponent {
|
||||||
protected readonly imageService = inject(ImageService);
|
protected readonly imageService = inject(ImageService);
|
||||||
protected readonly accountService = inject(AccountService);
|
protected readonly accountService = inject(AccountService);
|
||||||
private readonly themeService = inject(ThemeService);
|
private readonly themeService = inject(ThemeService);
|
||||||
|
private readonly toastr = inject(ToastrService);
|
||||||
|
|
||||||
protected readonly TagBadgeCursor = TagBadgeCursor;
|
protected readonly TagBadgeCursor = TagBadgeCursor;
|
||||||
|
|
||||||
|
|
@ -104,7 +106,14 @@ export class PersonDetailComponent {
|
||||||
this.personName = personName;
|
this.personName = personName;
|
||||||
return this.personService.get(personName);
|
return this.personService.get(personName);
|
||||||
}),
|
}),
|
||||||
tap(person => {
|
tap((person) => {
|
||||||
|
|
||||||
|
if (person == null) {
|
||||||
|
this.toastr.error(translate('toasts.unauthorized-1'));
|
||||||
|
this.router.navigateByUrl('/home');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.person = person;
|
this.person = person;
|
||||||
this.personSubject.next(person); // emit the person data for subscribers
|
this.personSubject.next(person); // emit the person data for subscribers
|
||||||
this.themeService.setColorScape(person.primaryColor || '', person.secondaryColor);
|
this.themeService.setColorScape(person.primaryColor || '', person.secondaryColor);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue