Skip to content

Commit

Permalink
default landing page fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
clemiller committed Jul 13, 2023
1 parent 47db7d3 commit cfb9fc5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const routes: Routes = [
},
"children": [
{
"path": "home",
"path": "",
"data": {
"breadcrumb": "welcome"
},
Expand Down
9 changes: 2 additions & 7 deletions app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ export class AppComponent implements AfterViewInit {
});
} else if (e instanceof NavigationEnd) {
const authSubscription = this.authenticationService.getSession().subscribe({
next: (res) => {
this.checkStatus();
if (this.router.url === '/') {
this.configService.redirectToLanding();
}
},
next: (res) => { this.checkStatus(); },
complete: () => { authSubscription.unsubscribe(); }
});
}
Expand Down Expand Up @@ -102,7 +97,7 @@ export class AppComponent implements AfterViewInit {
const logoutSubscription = this.authenticationService.logout().subscribe({
complete: () => {
this.sidebarService.opened = false;
this.router.navigate(['home']);
this.router.navigate(['']);
logoutSubscription.unsubscribe();
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/components/header/header.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<mat-toolbar class="header">
<!-- Title & Help -->
<div class="app-title">
<h1><a routerLink="/home">ATT&CK Workbench&nbsp;<span class="app-version lowercase">v{{app_version}}</span></a></h1>
<h1><a routerLink="">ATT&CK Workbench&nbsp;<span class="app-version lowercase">v{{app_version}}</span></a></h1>
</div>
<button mat-icon-button routerLink="/docs" matTooltip="help">
<mat-icon aria-label="help">help_outline</mat-icon>
Expand Down
6 changes: 3 additions & 3 deletions app/src/app/services/config/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class AppConfigService {

/** Get the default landing page route */
public get defaultLandingPage() {
if (!this.appConfig) return 'home';
if (!this.appConfig) return '';
return this.appConfig.defaultLandingPage;
}

Expand All @@ -27,10 +27,10 @@ export class AppConfigService {
if (this.defaultLandingPage && this.defaultLandingPage !== '') {
this.router.navigate([this.defaultLandingPage])
.catch(e => {
this.router.navigate(['/home'])
this.router.navigate([''])
})
} else {
this.router.navigate(['/home'])
this.router.navigate([''])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Role } from 'src/app/classes/authn/role';
import { Router } from '@angular/router';
import { RestApiConnectorService } from '../rest-api/rest-api-connector.service';
import { Status } from 'src/app/classes/authn/status';
import { AppConfigService } from '../../config/app-config.service';

@Injectable({
providedIn: 'root'
Expand All @@ -22,7 +23,13 @@ export class AuthenticationService extends ApiConnector {
private get apiUrl(): string { return environment.integrations.rest_api.url; }
public onLogin = new EventEmitter(); // event emitter for admin organization identity pop-up

constructor(private router: Router, private http: HttpClient, snackbar: MatSnackBar, private restAPIConnector: RestApiConnectorService) { super(snackbar); }
constructor(private router: Router,
private http: HttpClient,
snackbar: MatSnackBar,
private restAPIConnector: RestApiConnectorService,
private configService: AppConfigService) {
super(snackbar);
}

/**
* Check if user is authorized
Expand Down Expand Up @@ -73,7 +80,7 @@ export class AuthenticationService extends ApiConnector {
window.location.href = url;
return this.getSession().pipe(
map(res => {
this.onLogin.emit();
this.success();
return res;
})
);
Expand All @@ -83,7 +90,7 @@ export class AuthenticationService extends ApiConnector {
concatMap(success => {
return this.getSession().pipe(
map(res => {
this.onLogin.emit();
this.success();
return res;
})
);
Expand All @@ -95,6 +102,11 @@ export class AuthenticationService extends ApiConnector {
);
}

public success(): void {
this.configService.redirectToLanding();
this.onLogin.emit();
}

/**
* User logout sequence to clear the active login session on the REST API side
* Note: this does not log the user out of the organization's SSO Provider
Expand Down

0 comments on commit cfb9fc5

Please sign in to comment.