fix: Bug - User login status showing as both logged in and logged out
Stop treating transient auth_required as home-session expiry, keep auth scope consistent across login redirect and server-rail joins, and leave /login when the in-memory user is still authenticated. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
OnInit,
|
||||
signal
|
||||
@@ -13,11 +14,7 @@ import { Actions } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { NgIcon, provideIcons } from '@ng-icons/core';
|
||||
import { lucideLogIn } from '@ng-icons/lucide';
|
||||
import {
|
||||
filter,
|
||||
firstValueFrom,
|
||||
take
|
||||
} from 'rxjs';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
import { AuthenticationService } from '../../application/services/authentication.service';
|
||||
import { ServerDirectoryFacade } from '../../../server-directory';
|
||||
@@ -71,8 +68,27 @@ export class LoginComponent implements OnInit {
|
||||
private auth = inject(AuthenticationService);
|
||||
private actions$ = inject(Actions);
|
||||
private store = inject(Store);
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly currentUser = this.store.selectSignal(selectCurrentUser);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
if (this.isAuthorizeMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = this.currentUser();
|
||||
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
const returnUrl = resolveSafeReturnUrl(this.route.snapshot.queryParamMap.get('returnUrl'));
|
||||
|
||||
void this.router.navigateByUrl(returnUrl);
|
||||
});
|
||||
}
|
||||
|
||||
/** TrackBy function for server list rendering. */
|
||||
trackById(_index: number, item: { id: string }) { return item.id; }
|
||||
@@ -86,20 +102,6 @@ export class LoginComponent implements OnInit {
|
||||
if (requestedServerId) {
|
||||
this.serverId = requestedServerId;
|
||||
}
|
||||
|
||||
if (this.isAuthorizeMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.store.select(selectCurrentUser).pipe(
|
||||
filter(Boolean),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(() => {
|
||||
const returnUrl = resolveSafeReturnUrl(this.route.snapshot.queryParamMap.get('returnUrl'));
|
||||
|
||||
void this.router.navigateByUrl(returnUrl);
|
||||
});
|
||||
}
|
||||
|
||||
/** Validate and submit the login form, then navigate to search on success. */
|
||||
|
||||
Reference in New Issue
Block a user