Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Aug 29, 2024
1 parent 2437698 commit 69703bc
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 32 deletions.
1 change: 1 addition & 0 deletions docker/local-prod/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
angular:
container_name: angular
image: node:20
user: "${UID:-1000}:${GID:-1000}"
volumes:
- ../../../okr:/opt
- /etc/passwd:/etc/passwd:ro
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ActivatedRouteSnapshot, ResolveFn, RouterModule, Routes } from '@angula
import { OverviewComponent } from './overview/overview.component';
import { EMPTY, of } from 'rxjs';
import { SidepanelComponent } from './shared/custom/sidepanel/sidepanel.component';
import { authGuard } from './shared/guards/auth.guard';
import { AutoLoginPartialRoutesGuard } from 'angular-auth-oidc-client';
import { CallbackComponent } from './callback/callback.component';

Expand Down
6 changes: 2 additions & 4 deletions frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { OidcSecurityService } from 'angular-auth-oidc-client';

@Component({
Expand All @@ -10,8 +10,6 @@ import { OidcSecurityService } from 'angular-auth-oidc-client';
export class AppComponent implements OnInit {
constructor(private oidcSecurityService: OidcSecurityService) {}
ngOnInit(): void {
this.oidcSecurityService
.checkAuth()
.subscribe(({ isAuthenticated, userData, accessToken, idToken, configId }) => {});
this.oidcSecurityService.checkAuth().subscribe();
}
}
4 changes: 2 additions & 2 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ export const MY_FORMATS = {
},
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
{ provide: HTTP_INTERCEPTORS, useClass: OauthInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
// { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
// { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
{
provide: AbstractSecurityStorage,
useClass: DefaultLocalStorageService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ export class ApplicationTopBarComponent implements OnInit, OnDestroy {
}

username() {
return this.oauthService.getUserData().pipe(
map((user) => user?.name || 'No username available'),
switchMap((username) => (username ? of(username) : of('no username received'))),
);
return this.oauthService.getUserData().pipe(map((user) => user?.name || ''));
}

openTeamManagement() {
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/app/callback/callback.component.cy.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ export class KeyResultFormComponent implements OnInit {
]);

this.users$.subscribe((users) => {
const loggedInUser = this.getUserName();
users.forEach((user) => {
if (user.firstname + ' ' + user.lastname === loggedInUser) {
this.keyResultForm.controls['owner'].setValue(user);
}
this.getUserName().subscribe((userName) => {
users.forEach((user) => {
if (user.firstname + ' ' + user.lastname === userName) {
this.keyResultForm.controls['owner'].setValue(user);
}
});
});
});
}
Expand Down Expand Up @@ -131,7 +132,6 @@ export class KeyResultFormComponent implements OnInit {
updateFormValidity() {}

getUserName() {
// return this.oauthService.getUserData()['name'];
return '';
return this.oauthService.getUserData().pipe(map((user) => user?.name || ''));
}
}
7 changes: 2 additions & 5 deletions frontend/src/app/shared/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ import { inject } from '@angular/core';
import { OidcSecurityService } from 'angular-auth-oidc-client';
import { map, take } from 'rxjs';

//Not used, can be deleted
export const authGuard: CanActivateFn = (route, state) => {
const oidcSecurityService = inject(OidcSecurityService);
const router = inject(Router);

return oidcSecurityService.isAuthenticated$.pipe(
take(1),
map(({ isAuthenticated }) => {
// allow navigation if authenticated
if (isAuthenticated) {
return true;
}
return isAuthenticated;

// redirect if not authenticated
return router.parseUrl('/unauthorized');
}),
);
};
1 change: 0 additions & 1 deletion frontend/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const environment = {
oauth: {
decreaseExpirationBySec: 30,
clearHashAfterLogin: true,
secureRoutes: ['**', 'http://localhost:4200/', 'http://localhost:8080/', 'localhost:8080/'],
authority: 'https://sso.puzzle.ch/auth/realms/pitc',
strictDiscoveryDocumentValidation: false,
customQueryParams: { response_modes_supported: ['query'] },
Expand Down
1 change: 0 additions & 1 deletion frontend/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const environment = {
production: false,
staging: false,
oauth: {
secureRoutes: ['http://localhost:4200/', 'http://localhost:8080/'],
postLoginRoute: '/dashboard',
// decreaseExpirationBySec: 30,
// clearHashAfterLogin: true,
Expand Down

0 comments on commit 69703bc

Please sign in to comment.