Skip to content

Commit

Permalink
ci: Reenable deprecation ESLint rule
Browse files Browse the repository at this point in the history
We had to disable the deprecation rule due to many deprecated modules
after an Angular update. After replacing all deprecated modules step by step,
we can reenable the rule again.
  • Loading branch information
MoritzWeber0 committed Feb 7, 2024
1 parent c808389 commit c8def31
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = {
],
"unused-imports/no-unused-imports": "error",
"no-console": ["error", { allow: ["error"] }],
"deprecation/deprecation": "warn",
"deprecation/deprecation": "error",
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { NgModule } from '@angular/core';
import { Data, RouterModule, Routes } from '@angular/router';
import { authGuard } from 'src/app/general/auth/auth-guard/auth-guard.service';
import { JobRunOverviewComponent } from 'src/app/projects/models/backup-settings/job-run-overview/job-run-overview.component';
import { PipelineRunWrapperComponent } from 'src/app/projects/models/backup-settings/pipeline-runs/wrapper/pipeline-run-wrapper/pipeline-run-wrapper.component';
import { ViewLogsDialogComponent } from 'src/app/projects/models/backup-settings/view-logs-dialog/view-logs-dialog.component';
Expand All @@ -18,7 +19,6 @@ import { BasicAuthTokenComponent } from 'src/app/users/basic-auth-token/basic-au
import { UsersProfileComponent } from 'src/app/users/users-profile/users-profile.component';
import { EventsComponent } from './events/events.component';
import { AuthComponent } from './general/auth/auth/auth.component';
import { AuthGuardService } from './general/auth/auth-guard/auth-guard.service';
import { AuthRedirectComponent } from './general/auth/auth-redirect/auth-redirect.component';
import { LogoutComponent } from './general/auth/logout/logout/logout.component';
import { LogoutRedirectComponent } from './general/auth/logout/logout-redirect/logout-redirect.component';
Expand Down Expand Up @@ -51,7 +51,7 @@ import { SettingsComponent } from './settings/settings.component';
const routes: Routes = [
{
path: '',
canActivate: [AuthGuardService],
canActivate: [authGuard],
children: [
{
path: '',
Expand Down
41 changes: 15 additions & 26 deletions frontend/src/app/general/auth/auth-guard/auth-guard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,26 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Injectable } from '@angular/core';
import { inject } from '@angular/core';
import {
ActivatedRouteSnapshot,
CanActivate,
CanActivateFn,
RouterStateSnapshot,
UrlTree,
} from '@angular/router';
import { Observable } from 'rxjs';
import { AuthService } from 'src/app/services/auth/auth.service';

@Injectable({
providedIn: 'root',
})
export class AuthGuardService implements CanActivate {
constructor(private authService: AuthService) {}
export const authGuard: CanActivateFn = (
_route: ActivatedRouteSnapshot,
_state: RouterStateSnapshot,
) => {
const authService = inject(AuthService);

canActivate(
_route: ActivatedRouteSnapshot,
_state: RouterStateSnapshot,
):
| Observable<boolean | UrlTree>
| Promise<boolean | UrlTree>
| boolean
| UrlTree {
if (this.authService.isLoggedIn()) {
return true;
} else {
// Needs window.location, since Router.url isn't updated yet
this.authService.cacheCurrentPath(window.location.pathname);
this.authService.webSSO();
return false;
}
if (authService.isLoggedIn()) {
return true;
} else {
// Needs window.location, since Router.url isn't updated yet
authService.cacheCurrentPath(window.location.pathname);
authService.webSSO();
return false;
}
}
};

0 comments on commit c8def31

Please sign in to comment.