Skip to content

Commit 6b5bf7e

Browse files
authored
fix(settings): Update connectOrcid to properly logging user out (#934)
1 parent 17b1ad3 commit 6b5bf7e

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/app/core/services/auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ export class AuthService {
7373
window.location.href = loginUrl;
7474
}
7575

76-
logout(): void {
76+
logout(nextUrl?: string): void {
7777
this.loaderService.show();
7878
this.actions.clearCurrentUser();
7979

8080
if (isPlatformBrowser(this.platformId)) {
8181
this.cookieService.deleteAll();
82-
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent('/')}`;
82+
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent(nextUrl || '/')}`;
8383
}
8484
}
8585

src/app/features/settings/profile-settings/components/authenticated-identity/authenticated-identity.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { NgOptimizedImage } from '@angular/common';
1111
import { ChangeDetectionStrategy, Component, computed, inject, OnInit } from '@angular/core';
1212

1313
import { ENVIRONMENT } from '@core/provider/environment.provider';
14+
import { AuthService } from '@core/services/auth.service';
1415
import { ExternalIdentityStatus } from '@osf/shared/enums/external-identity-status.enum';
1516
import { CustomConfirmationService } from '@osf/shared/services/custom-confirmation.service';
1617
import { LoaderService } from '@osf/shared/services/loader.service';
@@ -31,6 +32,7 @@ import { ProfileSettingsTabOption } from '../../enums';
3132
changeDetection: ChangeDetectionStrategy.OnPush,
3233
})
3334
export class AuthenticatedIdentityComponent implements OnInit {
35+
private readonly authService = inject(AuthService);
3436
private readonly environment = inject(ENVIRONMENT);
3537
private readonly customConfirmationService = inject(CustomConfirmationService);
3638
private readonly toastService = inject(ToastService);
@@ -85,8 +87,6 @@ export class AuthenticatedIdentityComponent implements OnInit {
8587
service: `${webUrl}/login`,
8688
next: encodeURIComponent(finalDestination.toString()),
8789
}).toString();
88-
const logoutUrl = new URL(`${webUrl}/logout/`);
89-
logoutUrl.searchParams.set('next', casLoginUrl.toString());
90-
window.location.href = logoutUrl.toString();
90+
this.authService.logout(casLoginUrl.toString());
9191
}
9292
}

0 commit comments

Comments
 (0)