1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-21 16:18:28 +01:00

Inital PR for checking if the Link is still valid/the user still has access and rerouting them if not to the projects list (#5283)

This commit is contained in:
cd-bitwarden 2023-04-26 15:43:06 -04:00 committed by GitHub
parent 208e3f30b4
commit ad40d508e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,15 @@
import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { combineLatest, filter, Observable, startWith, Subject, switchMap, takeUntil } from "rxjs";
import { ActivatedRoute, Router } from "@angular/router";
import {
catchError,
combineLatest,
filter,
Observable,
startWith,
Subject,
switchMap,
takeUntil,
} from "rxjs";
import { DialogService } from "@bitwarden/components";
@ -27,7 +36,8 @@ export class ProjectComponent implements OnInit, OnDestroy {
constructor(
private route: ActivatedRoute,
private projectService: ProjectService,
private dialogService: DialogService
private dialogService: DialogService,
private router: Router
) {}
ngOnInit(): void {
@ -40,7 +50,8 @@ export class ProjectComponent implements OnInit, OnDestroy {
this.project$ = combineLatest([this.route.params, currentProjectEdited]).pipe(
switchMap(([params, _]) => {
return this.projectService.getByProjectId(params.projectId);
})
}),
catchError(async () => this.handleError())
);
this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => {
@ -49,6 +60,12 @@ export class ProjectComponent implements OnInit, OnDestroy {
});
}
handleError = () => {
const projectsListUrl = `/sm/${this.organizationId}/projects/`;
this.router.navigate([projectsListUrl]);
return new ProjectPermissionDetailsView();
};
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();