Skip to content

Commit 46e7cd0

Browse files
committed
fix: Fix impossible to cancel when login success page is present
1 parent bf92e70 commit 46e7cd0

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

apps/browser/src/auth/popup/home.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
22
import { 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

66
import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component";
77
import { 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
/*

apps/browser/src/auth/popup/login-v1.component.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@
1111
-->
1212
<header>
1313
<div class="left">
14-
<button type="button" routerLink="/home">
14+
<button type="button" routerLink="/home" [queryParams]="{ noRedirect: true }">
1515
<span>{{ "cancel" | i18n }}</span>
1616
</button>
1717
</div>
1818
<h1 class="center">
1919
<span class="title">{{ "appName" | i18n }}</span>
2020
</h1>
2121
<div class="right">
22-
<button type="button" routerLink="/home" style="visibility: hidden">
22+
<button
23+
type="button"
24+
routerLink="/home"
25+
[queryParams]="{ noRedirect: true }"
26+
style="visibility: hidden"
27+
>
2328
<span>{{ "cancel" | i18n }}</span>
2429
</button>
2530
</div>

0 commit comments

Comments
 (0)