mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[pm-5287] fix account switch logout routing (#7231)
* Navigate to home from account switcher Also updates the main background handling of logout to either finish switch or logout, depending on which occurred * Prefer observable guards we were racing the account switch process on `accountService` and this async guard. It only depended on account status, which is available from `accountService`, so the correct move was to observe that status. The unauthGuardFn allows for updating homepage depending on window state because popout windows have different nav to other locations.
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
AuthGuard,
|
||||
lockGuard,
|
||||
tdeDecryptionRequiredGuard,
|
||||
UnauthGuard,
|
||||
unauthGuardFn,
|
||||
} from "@bitwarden/angular/auth/guards";
|
||||
import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
@@ -28,6 +28,7 @@ import { TwoFactorOptionsComponent } from "../auth/popup/two-factor-options.comp
|
||||
import { TwoFactorComponent } from "../auth/popup/two-factor.component";
|
||||
import { UpdateTempPasswordComponent } from "../auth/popup/update-temp-password.component";
|
||||
import { AutofillComponent } from "../autofill/popup/settings/autofill.component";
|
||||
import BrowserPopupUtils from "../platform/popup/browser-popup-utils";
|
||||
import { GeneratorComponent } from "../tools/popup/generator/generator.component";
|
||||
import { PasswordGeneratorHistoryComponent } from "../tools/popup/generator/password-generator-history.component";
|
||||
import { SendAddEditComponent } from "../tools/popup/send/send-add-edit.component";
|
||||
@@ -57,6 +58,12 @@ import { SettingsComponent } from "./settings/settings.component";
|
||||
import { SyncComponent } from "./settings/sync.component";
|
||||
import { TabsComponent } from "./tabs.component";
|
||||
|
||||
const unauthRouteOverrides = {
|
||||
homepage: () => {
|
||||
return BrowserPopupUtils.inPopout(window) ? "/tabs/vault" : "/tabs/current";
|
||||
},
|
||||
};
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: "",
|
||||
@@ -74,7 +81,7 @@ const routes: Routes = [
|
||||
{
|
||||
path: "home",
|
||||
component: HomeComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "home" },
|
||||
},
|
||||
{
|
||||
@@ -86,7 +93,7 @@ const routes: Routes = [
|
||||
{
|
||||
path: "login",
|
||||
component: LoginComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "login" },
|
||||
},
|
||||
{
|
||||
@@ -110,13 +117,13 @@ const routes: Routes = [
|
||||
{
|
||||
path: "2fa",
|
||||
component: TwoFactorComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "2fa" },
|
||||
},
|
||||
{
|
||||
path: "2fa-options",
|
||||
component: TwoFactorOptionsComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "2fa-options" },
|
||||
},
|
||||
{
|
||||
@@ -130,7 +137,7 @@ const routes: Routes = [
|
||||
{
|
||||
path: "sso",
|
||||
component: SsoComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "sso" },
|
||||
},
|
||||
{
|
||||
@@ -147,19 +154,19 @@ const routes: Routes = [
|
||||
{
|
||||
path: "register",
|
||||
component: RegisterComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "register" },
|
||||
},
|
||||
{
|
||||
path: "hint",
|
||||
component: HintComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "hint" },
|
||||
},
|
||||
{
|
||||
path: "environment",
|
||||
component: EnvironmentComponent,
|
||||
canActivate: [UnauthGuard],
|
||||
canActivate: [unauthGuardFn(unauthRouteOverrides)],
|
||||
data: { state: "environment" },
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user