mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +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:
parent
208e3f30b4
commit
ad40d508e8
@ -1,6 +1,15 @@
|
|||||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { combineLatest, filter, Observable, startWith, Subject, switchMap, takeUntil } from "rxjs";
|
import {
|
||||||
|
catchError,
|
||||||
|
combineLatest,
|
||||||
|
filter,
|
||||||
|
Observable,
|
||||||
|
startWith,
|
||||||
|
Subject,
|
||||||
|
switchMap,
|
||||||
|
takeUntil,
|
||||||
|
} from "rxjs";
|
||||||
|
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
@ -27,7 +36,8 @@ export class ProjectComponent implements OnInit, OnDestroy {
|
|||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private dialogService: DialogService
|
private dialogService: DialogService,
|
||||||
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -40,7 +50,8 @@ export class ProjectComponent implements OnInit, OnDestroy {
|
|||||||
this.project$ = combineLatest([this.route.params, currentProjectEdited]).pipe(
|
this.project$ = combineLatest([this.route.params, currentProjectEdited]).pipe(
|
||||||
switchMap(([params, _]) => {
|
switchMap(([params, _]) => {
|
||||||
return this.projectService.getByProjectId(params.projectId);
|
return this.projectService.getByProjectId(params.projectId);
|
||||||
})
|
}),
|
||||||
|
catchError(async () => this.handleError())
|
||||||
);
|
);
|
||||||
|
|
||||||
this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
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 {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
|
Loading…
Reference in New Issue
Block a user