[WebApp] AccountSwitcher

This commit is contained in:
2026-07-22 13:56:09 +02:00
parent 3759d3f6c6
commit 1074749cd0
7 changed files with 405 additions and 60 deletions
@@ -137,7 +137,12 @@ export class AccountInfoComponent implements OnInit {
next: () => {
this.notification.success('Account deleted');
this.authService.logout();
this.router.navigate(['/login']);
if (this.authService.isAuthenticated()) {
// Another account is still logged in — reload into it cleanly.
window.location.assign('/');
} else {
this.router.navigate(['/login']);
}
},
error: () => {
this.deleting.set(false);
@@ -1,6 +1,6 @@
import { Component, inject, signal } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { NzInputModule } from 'ng-zorro-antd/input';
import { NzButtonModule } from 'ng-zorro-antd/button';
@@ -27,7 +27,6 @@ import { isAdminKey } from '../../../core/models';
export class LoginComponent {
private authService = inject(AuthService);
private apiService = inject(ApiService);
private router = inject(Router);
private route = inject(ActivatedRoute);
userId = '';
@@ -56,9 +55,11 @@ export class LoginComponent {
return;
}
// Login successful
// Login successful. Use a full navigation so all per-account state
// (singleton caches, component signals) is initialised for the new
// active account — important when adding a second account.
const returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/messages';
this.router.navigateByUrl(returnUrl);
window.location.assign(returnUrl);
},
error: (err) => {
this.authService.logout();