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

Hotfix: Delayed Load in Anonymous Mode #359

Merged
merged 2 commits into from
Nov 28, 2024
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
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { ENTER } from '@angular/cdk/keycodes';
import { HttpClient } from '@angular/common/http';
import {
ChangeDetectionStrategy,
Component,
ElementRef,
inject,
Input,
OnInit,
Output,
ViewChild,
} from '@angular/core';
import { Component, ElementRef, inject, Input, OnInit, Output, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { appSharedStateActions, AuthService, fromAppShared } from '@asset-sg/client-shared';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
Expand All @@ -24,7 +15,6 @@ import { Version } from './version';
selector: 'asset-sg-app-bar',
templateUrl: './app-bar.component.html',
styleUrls: ['./app-bar.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppBarComponent implements OnInit {
// TODO use new pattern here
Expand Down
18 changes: 10 additions & 8 deletions libs/client-shared/src/lib/features/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export class AuthService {
private readonly _isInitialized$ = new BehaviorSubject(false);

async initialize(oAuthConfig: Record<string, unknown>) {
if (oAuthConfig['anonymous_mode']) {
const isAnonymous = oAuthConfig['anonymous_mode'];
if (isAnonymous) {
this.setState(AuthState.Success);
this.store.dispatch(appSharedStateActions.setAnonymousMode());
} else {
Expand All @@ -50,6 +51,14 @@ export class AuthService {
this.store.dispatch(appSharedStateActions.loadUserProfile());
}
this._isInitialized$.next(true);

const isLoggedIn = isAnonymous || this._state$.value === AuthState.Success;
if (isLoggedIn && !this.configService.getHideDisclaimer()) {
this.dialogService.open(DisclaimerDialogComponent, {
width: '500px',
disableClose: true,
});
}
}

async signIn(): Promise<void> {
Expand All @@ -62,13 +71,6 @@ export class AuthService {
// If something else has interrupted the auth process, then we don't want to signal a success.
if (this._state$.value === AuthState.Ongoing) {
this._state$.next(AuthState.Success);

if (!this.configService.getHideDisclaimer()) {
this.dialogService.open(DisclaimerDialogComponent, {
width: '500px',
disableClose: true,
});
}
}
}
} else {
Expand Down