Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove getAuthenticationState #1056

Merged
merged 1 commit into from
Nov 7, 2023
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: 0 additions & 4 deletions ui/src/app/account/service/account.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'
import { SessionStorageService } from 'ngx-webstorage'
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'
import { BehaviorSubject, EMPTY, Observable, Subject, catchError, map, of, takeUntil, tap } from 'rxjs'

Check warning on line 4 in ui/src/app/account/service/account.service.ts

View workflow job for this annotation

GitHub Actions / format

'of' is defined but never used

Check warning on line 4 in ui/src/app/account/service/account.service.ts

View workflow job for this annotation

GitHub Actions / format

'tap' is defined but never used

import { SERVER_API_URL } from '../../../app/app.constants'
import { IAccount } from '../model/account.model'
Expand All @@ -14,7 +14,7 @@
private isFetchingAccountData = false
private stopFetchingAccountData = new Subject()
private authenticated = false
private authenticationState = new BehaviorSubject<any>(null)

Check warning on line 17 in ui/src/app/account/service/account.service.ts

View workflow job for this annotation

GitHub Actions / format

Unexpected any. Specify a different type
private logoutAsResourceUrl = SERVER_API_URL + 'services/userservice/api'

constructor(
Expand Down Expand Up @@ -137,10 +137,6 @@
return this.accountData.value !== undefined
}

getAuthenticationState(): Observable<any> {
return this.accountData.asObservable()
}

getImageUrl(): string | null {
return this.isIdentityResolved() ? this.accountData.value!.imageUrl : null
}
Expand Down
7 changes: 3 additions & 4 deletions ui/src/app/layout/navbar/navbar.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('NavbarComponent', () => {
'getAccountData',
'isAuthenticated',
'hasAnyAuthority',
'getAuthenticationState',
'isLoggedAs',
'isOrganizationOwner',
'getImageUrl',
Expand Down Expand Up @@ -60,7 +59,7 @@ describe('NavbarComponent', () => {
accountService.isOrganizationOwner.and.returnValue(false)
accountService.getImageUrl.and.returnValue(null)
accountService.getSalesforceId.and.returnValue('sfid')
accountService.getAuthenticationState.and.returnValue(
accountService.getAccountData.and.returnValue(
of({
activated: true,
authorities: ['ROLE_USER'],
Expand Down Expand Up @@ -105,7 +104,7 @@ describe('NavbarComponent', () => {
accountService.isOrganizationOwner.and.returnValue(false)
accountService.getImageUrl.and.returnValue(null)
accountService.getSalesforceId.and.returnValue('sfid')
accountService.getAuthenticationState.and.returnValue(
accountService.getAccountData.and.returnValue(
of({
activated: true,
authorities: ['ROLE_USER', 'ROLE_CONSORTIUM_LEAD'],
Expand Down Expand Up @@ -143,7 +142,7 @@ describe('NavbarComponent', () => {
accountService.isOrganizationOwner.and.returnValue(false)
accountService.getImageUrl.and.returnValue(null)
accountService.getSalesforceId.and.returnValue('sfid')
accountService.getAuthenticationState.and.returnValue(
accountService.getAccountData.and.returnValue(
of({
activated: true,
authorities: ['ROLE_USER', 'ASSERTION_SERVICE_ENABLED'],
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/layout/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ export class NavbarComponent implements OnInit {
}

ngOnInit() {
this.accountService.getAuthenticationState().subscribe(() => {
this.accountService.getAccountData().subscribe(() => {
if (!this.memberCallDone && this.isAuthenticated() && this.hasRoleUser()) {
this.memberCallDone = true

const salesforceId = this.accountService.getSalesforceId()
if (salesforceId) {
this.memberService.find(salesforceId).subscribe({
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/directive/has-any-authority.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class HasAnyAuthorityDirective {
this.authorities = typeof value === 'string' ? [value] : value
this.updateView()
// Get notified each time authentication state changes.
this.accountService.getAuthenticationState().subscribe((identity) => this.updateView())
this.accountService.getAccountData().subscribe((identity) => this.updateView())
}

private updateView(): void {
Expand Down
Loading