11import { Component , OnDestroy , OnInit , ViewChild } from "@angular/core" ;
22import { FormBuilder } from "@angular/forms" ;
3- import { Router } from "@angular/router" ;
4- import { Subject , firstValueFrom } from "rxjs" ;
3+ import { ActivatedRoute , Router } from "@angular/router" ;
4+ import { Subject , firstValueFrom , first , takeUntil } from "rxjs" ;
55
66import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component" ;
77import { LoginEmailServiceAbstraction , RegisterRouteService } from "@bitwarden/auth/common" ;
@@ -61,6 +61,7 @@ export class HomeComponent implements OnInit, OnDestroy {
6161 private accountSwitcherService : AccountSwitcherService ,
6262 private registerRouteService : RegisterRouteService ,
6363 private toastService : ToastService ,
64+ private route : ActivatedRoute ,
6465 ) { }
6566
6667 async ngOnInit ( ) : Promise < void > {
@@ -77,7 +78,13 @@ export class HomeComponent implements OnInit, OnDestroy {
7778 }
7879 }
7980
80- this . redirectIfSSOLoginSuccessTab ( ) ;
81+ // Cozy customization; avoid redirection if coming after a "Cancel" from login view
82+ this . route . queryParams . pipe ( first ( ) , takeUntil ( this . destroyed$ ) ) . subscribe ( ( params ) => {
83+ if ( ! params . noRedirect ) {
84+ this . redirectIfSSOLoginSuccessTab ( ) ;
85+ }
86+ } ) ;
87+ // Cozy customization
8188
8289 // Cozy customization
8390 /*
0 commit comments