Skip to content

Commit

Permalink
b
Browse files Browse the repository at this point in the history
  • Loading branch information
polterguy committed Dec 18, 2023
1 parent 5859d6e commit 7a8ea09
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions frontend/src/app/access.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ export class AccessGuard implements CanActivate {
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {

return (async () => {

if (this.backendService.active?.token?.in_role('root')) {
return true;
}

this.router.navigate(['/authentication/login/'], {
queryParams: route.queryParams
});

})();

}
}
2 changes: 1 addition & 1 deletion frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
*ngIf="loading$ | async">
</mat-progress-bar>

<router-outlet></router-outlet>
<router-outlet></router-outlet>
15 changes: 5 additions & 10 deletions frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { AfterContentChecked, ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import { Subject, BehaviorSubject } from 'rxjs';
import { GeneralService } from './_general/services/general.service';
import { ThemeService } from './_general/services/theme.service';

/**
* Primary component for dashboard, encapsulating progress bar, and router outlet.
Expand All @@ -18,26 +17,22 @@ import { ThemeService } from './_general/services/theme.service';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent implements AfterContentChecked {
title = 'Aista Magic Cloud';
title = 'AINIRO.IO Magic Cloud';

loading$: Subject<any> = new BehaviorSubject(true);

/**
*
* @param loader To handle the loader generally.
* @param cdr To detect changes for handling the loader.
*/
constructor(
private generalService: GeneralService,
private themeService: ThemeService,
private cdr: ChangeDetectorRef) {
}

ngAfterContentChecked(): void {
ngAfterContentChecked() {

this.generalService.loading$.subscribe((res: any) => {

this.cdr.markForCheck();
this.loading$.next(res)
this.cdr.detectChanges();
})
});
}
}
1 change: 1 addition & 0 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { CoreComponent } from './_layout/core/core.component';
import { HeaderComponent } from './_layout/header/header.component';
import { FooterComponent } from './_layout/footer/footer.component';

// Misc
import { AccessGuard } from './access.guard';
import { AuthBaseComponent } from './public/authentication/auth-base/auth-base.component';
import { SharedModule } from './shared.module';
Expand Down

0 comments on commit 7a8ea09

Please sign in to comment.