Skip to content

Commit

Permalink
Add /unauthorized and /forbidden
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrik Dyrvold committed Sep 15, 2021
1 parent 3719016 commit 50969ed
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { ProjectListComponent } from './projects/project-list/project-list.compo
import { ProjectDetailsComponent } from './projects/project-details/project-details.component';
import { BuildDetailsComponent } from './builds/build-details/build-details.component';
import { LoginComponent } from './auth/login/login.component';
import { UnauthorizedComponent } from './auth/unauthorized/unauthorized.component';
import { ForbiddenComponent } from './auth/forbidden/forbidden.component';


const routes: Routes = [
{ path: '', component: ProjectListComponent },
{ path: 'project/:projectId', component: ProjectDetailsComponent },
{ path: 'build/:projectId/:buildId', component: BuildDetailsComponent },
{ path: 'login', component: LoginComponent },
{ path: 'unauthorized', component: UnauthorizedComponent},
{ path: 'forbidden', component: ForbiddenComponent},
];

@NgModule({
Expand Down
24 changes: 3 additions & 21 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ import { TooltipModule } from 'primeng/tooltip';
import { SyntaxHighlightService } from './shared/syntax-highlight/syntax-highlight.service';
import { SharedModule } from './shared/pipes/shared.module';
import { NavModule } from './nav/nav.module';
import { AuthConfigModule } from './auth/auth-config.module';
import { DialogModule } from 'primeng/dialog';
import { RouterModule } from '@angular/router';
import { LoginComponent } from './auth/login/login.component';
import { EventTypes, PublicEventsService } from 'angular-auth-oidc-client';
import { filter } from 'rxjs/operators';
import { ButtonModule } from 'primeng/button';
import { WharfAuthInterceptor } from './auth/wharf-auth.interceptor';
import { AuthModule } from './auth/auth.module';

@NgModule({
declarations: [
AppComponent,
LoginComponent,
],
imports: [
BrowserModule,
Expand All @@ -41,10 +35,7 @@ import { WharfAuthInterceptor } from './auth/wharf-auth.interceptor';
MenuModule,
TooltipModule,
SharedModule,
AuthConfigModule,
DialogModule,
RouterModule,
ButtonModule,
AuthModule,
],
providers: [
{
Expand All @@ -62,13 +53,4 @@ import { WharfAuthInterceptor } from './auth/wharf-auth.interceptor';
],
bootstrap: [AppComponent],
})
export class AppModule {
constructor(private readonly eventService: PublicEventsService) {
this.eventService
.registerForEvents()
.pipe(filter((notification) => notification.type === EventTypes.ConfigLoaded))
.subscribe((config) => {
console.log('ConfigLoaded', config);
});
}
}
export class AppModule { }
2 changes: 2 additions & 0 deletions src/app/auth/auth-config.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { NgModule } from '@angular/core';
import { AuthModule, LogLevel } from 'angular-auth-oidc-client';
// eslint-disable-next-line max-len
import { OpenIdConfiguration } from '../../../../angular-auth-oidc-client/projects/angular-auth-oidc-client/src/lib/config/openid-configuration';


@NgModule({
Expand Down
4 changes: 4 additions & 0 deletions src/app/auth/forbidden/forbidden.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="p-d-flex p-ac-center p-ai-center">
<h1>Forbidden</h1>
<p>Code 403</p>
</div>
Empty file.
25 changes: 25 additions & 0 deletions src/app/auth/forbidden/forbidden.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ForbiddenComponent } from './forbidden.component';

describe('ForbiddenComponent', () => {
let component: ForbiddenComponent;
let fixture: ComponentFixture<ForbiddenComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ForbiddenComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ForbiddenComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/auth/forbidden/forbidden.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'wh-forbidden',
templateUrl: './forbidden.component.html',
styleUrls: ['./forbidden.component.scss']
})
export class ForbiddenComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
4 changes: 4 additions & 0 deletions src/app/auth/unauthorized/unauthorized.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="p-d-flex p-ac-center p-ai-center">
<h1>Unauthorized</h1>
<p>Code 403</p>
</div>
Empty file.
25 changes: 25 additions & 0 deletions src/app/auth/unauthorized/unauthorized.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UnauthorizedComponent } from './unauthorized.component';

describe('UnauthorizedComponent', () => {
let component: UnauthorizedComponent;
let fixture: ComponentFixture<UnauthorizedComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UnauthorizedComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(UnauthorizedComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/auth/unauthorized/unauthorized.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'wh-unauthorized',
templateUrl: './unauthorized.component.html',
styleUrls: ['./unauthorized.component.scss']
})
export class UnauthorizedComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}

0 comments on commit 50969ed

Please sign in to comment.