Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ export class AuthService {
window.location.href = loginUrl;
}

logout(): void {
logout(nextUrl?: string): void {
this.loaderService.show();
this.actions.clearCurrentUser();

if (isPlatformBrowser(this.platformId)) {
this.cookieService.deleteAll();
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent('/')}`;
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent(nextUrl || '/')}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed this. The BE logout endpoint will redirect to CAS logout endpoint automatically, so this should work and answers my previous question.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { NgOptimizedImage } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, inject, OnInit } from '@angular/core';

import { ENVIRONMENT } from '@core/provider/environment.provider';
import { AuthService } from '@core/services/auth.service';
import { ExternalIdentityStatus } from '@osf/shared/enums/external-identity-status.enum';
import { CustomConfirmationService } from '@osf/shared/services/custom-confirmation.service';
import { LoaderService } from '@osf/shared/services/loader.service';
Expand All @@ -31,6 +32,7 @@ import { ProfileSettingsTabOption } from '../../enums';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AuthenticatedIdentityComponent implements OnInit {
private readonly authService = inject(AuthService);
private readonly environment = inject(ENVIRONMENT);
private readonly customConfirmationService = inject(CustomConfirmationService);
private readonly toastService = inject(ToastService);
Expand Down Expand Up @@ -85,8 +87,6 @@ export class AuthenticatedIdentityComponent implements OnInit {
service: `${webUrl}/login`,
next: encodeURIComponent(finalDestination.toString()),
}).toString();
const logoutUrl = new URL(`${webUrl}/logout/`);
logoutUrl.searchParams.set('next', casLoginUrl.toString());
window.location.href = logoutUrl.toString();
this.authService.logout(casLoginUrl.toString());
Comment on lines -88 to +90
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix. Just make sure that I understand: this.authService.logout() log user out of angular, BE and CAS?

  1. log out of angular FE session
  2. log our of BE session
  3. the BE logout process in 2 automatically handle CAS logout too

}
}
Loading