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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ yarn-error.log
/libpeerconnection.log
testem.log
/typings
/scripts/*

# System files
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions dist/1326.39315078aac2e872.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/4703.3328b0e1ef6dcef5.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/599.b92432fc4ce0fa18.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/6371.fe6b951f035db770.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/main.11be88ecd57e3ca0.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/runtime.4cc166407bbb79bf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/styles.2f93189c20193df0.css

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/app/adf-user-management/guards/url-query-login.guard.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { inject } from '@angular/core';
import { Router, ActivatedRouteSnapshot } from '@angular/router';
import { Router } from '@angular/router';
import { DfAuthService } from '../services/df-auth.service';
import { catchError, map, of } from 'rxjs';
import { ROUTES } from '../../shared/types/routes';
import { getHashAwareQueryParams } from '../../shared/utilities/url';

export const urlQueryLoginGuard = (next: ActivatedRouteSnapshot) => {
export const urlQueryLoginGuard = () => {
const router = inject(Router);
const authService = inject(DfAuthService);
const sessionToken = next.queryParams['session_token'];

const urlParams = getHashAwareQueryParams();
const sessionToken = urlParams.get('session_token');

if (sessionToken) {
return authService.loginWithToken().pipe(
Expand Down
8 changes: 1 addition & 7 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { DfLoadingSpinnerService } from './shared/services/df-loading-spinner.service';
import { NgIf, AsyncPipe } from '@angular/common';
import {
RouterOutlet,
Router,
ActivatedRoute,
NavigationEnd,
} from '@angular/router';
import { RouterOutlet, Router, ActivatedRoute } from '@angular/router';
import { DfSideNavComponent } from './shared/components/df-side-nav/df-side-nav.component';
import { DfEngagementBannerComponent } from './shared/components/df-engagement-banner/df-engagement-banner.component';
import { DfLicenseCheckService } from './shared/services/df-license-check.service';
Expand All @@ -15,7 +10,6 @@ import { AuthService } from './shared/services/auth.service';
import { LoggingService } from './shared/services/logging.service';
import { LoginResponse } from './shared/types/auth.types';
import { ROUTES } from './shared/types/routes';
import { filter } from 'rxjs/operators';
import { IntercomService } from './shared/services/intercom.service';
import { DfUserDataService } from './shared/services/df-user-data.service';

Expand Down
11 changes: 10 additions & 1 deletion src/app/shared/guards/logged-in.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { DfAuthService } from '../../adf-user-management/services/df-auth.servic
import { map, switchMap } from 'rxjs/operators';
import { Router } from '@angular/router';
import { ROUTES } from '../types/routes';
import { of } from 'rxjs';
import { EMPTY, of } from 'rxjs';
import { DfUserDataService } from '../services/df-user-data.service';
import { handleRedirectIfPresent } from '../utilities/url';

export const loggedInGuard = () => {
const authService = inject(DfAuthService);
Expand All @@ -18,10 +19,18 @@ export const loggedInGuard = () => {
if (!validSession) {
return router.createUrlTree([ROUTES.AUTH]);
}
// Session is valid, check for redirect
if (handleRedirectIfPresent(userDataService.token)) {
return false; // Prevent Angular navigation, external redirect in progress
}
return true;
})
);
}
// Already logged in, check for redirect
if (handleRedirectIfPresent(userDataService.token)) {
return EMPTY; // Don't emit, external redirect in progress
}
return of(true);
})
);
Expand Down
14 changes: 13 additions & 1 deletion src/app/shared/guards/not-logged-in.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@ import { map, switchMap } from 'rxjs/operators';
import { Router } from '@angular/router';
import { ROUTES } from '../types/routes';
import { DfUserDataService } from '../services/df-user-data.service';
import { of } from 'rxjs';
import { EMPTY, of } from 'rxjs';
import { captureRedirectUrl, handleRedirectIfPresent } from '../utilities/url';

export const notLoggedInGuard = () => {
const authService = inject(DfAuthService);
const userDataService = inject(DfUserDataService);
const router = inject(Router);

captureRedirectUrl();

return userDataService.isLoggedIn$.pipe(
switchMap(isLoggedIn => {
if (!isLoggedIn) {
return authService.checkSession().pipe(
map(validSession => {
if (validSession) {
// User has valid session, check for redirect
if (handleRedirectIfPresent(userDataService.token)) {
return false; // External redirect in progress
}
return router.createUrlTree([ROUTES.HOME]);
}
return true;
})
);
}
// Already logged in, check for redirect
if (handleRedirectIfPresent(userDataService.token)) {
return EMPTY; // External redirect in progress
}
return of(router.createUrlTree([ROUTES.HOME]));
})
);
Expand Down
Loading