From 00d5498e0037c20bdb16e3fd9d5ae9fb66075599 Mon Sep 17 00:00:00 2001 From: Bastian Wagner Date: Fri, 13 Sep 2024 21:42:05 +0200 Subject: [PATCH] environment --- api/src/modules/auth/auth.controller.ts | 1 + api/src/modules/auth/auth.service.ts | 5 ++- client/angular.json | 16 ++++---- client/src/app/core/auth/auth.service.ts | 16 +++++--- .../src/app/core/layout/layout.component.html | 10 ++--- .../src/app/core/layout/layout.component.scss | 12 +++++- .../dashboard/dashboard.component.html | 7 ---- .../modules/dashboard/dashboard.component.ts | 38 +------------------ .../environments/environment.development.ts | 3 -- client/src/environments/environment.prod.ts | 3 ++ client/src/environments/environment.ts | 2 +- 11 files changed, 43 insertions(+), 70 deletions(-) delete mode 100644 client/src/environments/environment.development.ts create mode 100644 client/src/environments/environment.prod.ts diff --git a/api/src/modules/auth/auth.controller.ts b/api/src/modules/auth/auth.controller.ts index d96c896..17cb44a 100644 --- a/api/src/modules/auth/auth.controller.ts +++ b/api/src/modules/auth/auth.controller.ts @@ -22,6 +22,7 @@ export class AuthController { @Body() authDto: AuthCodeDto, ): Promise { const user = await this.authService.registerOrLoginWithAuthCode(authDto); + console.log(user) if (user == null) { throw new HttpException('forbidden', HttpStatus.FORBIDDEN); } diff --git a/api/src/modules/auth/auth.service.ts b/api/src/modules/auth/auth.service.ts index 957cf2e..f802dbc 100644 --- a/api/src/modules/auth/auth.service.ts +++ b/api/src/modules/auth/auth.service.ts @@ -27,6 +27,9 @@ export class AuthService { this.http.post(url, body).subscribe({ next: async (response) => { const user = await this.saveExternalTokens(response.data as any); + if (!user) { + return resolve(null); + } this.generateTokens(user); resolve(user); }, @@ -55,7 +58,7 @@ export class AuthService { }); } if (!user.isActive) { - throw new HttpException('not active', HttpStatus.FORBIDDEN); + return resolve(null); } user.firstName = payload.firstName; diff --git a/client/angular.json b/client/angular.json index 02c5ba5..31adbe5 100644 --- a/client/angular.json +++ b/client/angular.json @@ -53,18 +53,18 @@ "maximumError": "40kB" } ], - "outputHashing": "all" + "outputHashing": "all", + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ] }, "development": { "optimization": false, "extractLicenses": false, - "sourceMap": true, - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.development.ts" - } - ] + "sourceMap": true } }, "defaultConfiguration": "production" diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 8351257..7a557f0 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -3,7 +3,7 @@ import { inject, Injectable } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { BehaviorSubject, Observable, tap, of, catchError } from 'rxjs'; import { IUser } from '../../model/interface/user.interface'; -import { environment } from '../../../environments/environment.development'; +import { environment } from '../../../environments/environment'; import { HotToastService } from '@ngxpert/hot-toast'; @Injectable({ @@ -48,10 +48,16 @@ export class AuthService { authenticateWithCode(authcode: string) { return new Promise(resolve => { - this.http.post('/api/auth/auth-code', { code: authcode }).subscribe(user => { - this.setTokens({ accessToken: user.accessToken, refreshToken: user.refreshToken}); - this.user = user; - return resolve(true) + this.http.post('/api/auth/auth-code', { code: authcode }).subscribe({ + next: user => { + this.setTokens({ accessToken: user.accessToken, refreshToken: user.refreshToken}); + this.user = user; + return resolve(true) + }, + error: () => { + this.toast.error('Login nicht erfolgreich!'); + return resolve(null); + } }) }) } diff --git a/client/src/app/core/layout/layout.component.html b/client/src/app/core/layout/layout.component.html index eb9d634..9c2daa5 100644 --- a/client/src/app/core/layout/layout.component.html +++ b/client/src/app/core/layout/layout.component.html @@ -2,11 +2,8 @@ - Keyvault - - + + @@ -14,7 +11,8 @@ -sdf + + diff --git a/client/src/app/core/layout/layout.component.scss b/client/src/app/core/layout/layout.component.scss index d4eae9c..8a5803b 100644 --- a/client/src/app/core/layout/layout.component.scss +++ b/client/src/app/core/layout/layout.component.scss @@ -8,11 +8,13 @@ mat-drawer-container { flex: 1 1 auto; } -.example-spacer { +.spacer { flex: 1 1 auto; } - +.logo { + cursor: pointer; +} mat-drawer, mat-toolbar { background-color: #fff; @@ -21,4 +23,10 @@ mat-drawer, mat-toolbar { .main_sidenav{ width: 200px; +} + +mat-drawer { + button { + width: 100%; + } } \ No newline at end of file diff --git a/client/src/app/modules/dashboard/dashboard.component.html b/client/src/app/modules/dashboard/dashboard.component.html index 3190ef6..e69de29 100644 --- a/client/src/app/modules/dashboard/dashboard.component.html +++ b/client/src/app/modules/dashboard/dashboard.component.html @@ -1,7 +0,0 @@ - \ No newline at end of file diff --git a/client/src/app/modules/dashboard/dashboard.component.ts b/client/src/app/modules/dashboard/dashboard.component.ts index e324dda..36dc5b2 100644 --- a/client/src/app/modules/dashboard/dashboard.component.ts +++ b/client/src/app/modules/dashboard/dashboard.component.ts @@ -11,41 +11,5 @@ import { ColDef } from 'ag-grid-community'; // Column Definition Type Interface }) export class DashboardComponent { - defaultColDef: ColDef = { - flex: 1, - editable: true -}; - rowData = [ - { make: "Tesla", model: "Model Y", price: 64950, electric: true }, - { make: "Ford", model: "F-Series", price: 33850, electric: false }, - { make: "Toyota", model: "Corolla", price: 29600, electric: false }, - { make: "Tesla", model: "Model Y", price: 64950, electric: true }, - { make: "Ford", model: "F-Series", price: 33850, electric: false }, - { make: "Toyota", model: "Corolla", price: 29600, electric: false }, - { make: "Tesla", model: "Model Y", price: 64950, electric: true }, - { make: "Ford", model: "F-Series", price: 33850, electric: false }, - { make: "Toyota", model: "Corolla", price: 29600, electric: false }, - { make: "Tesla", model: "Model Y", price: 64950, electric: true }, - ]; - - // Column Definitions: Defines the columns to be displayed. - colDefs: ColDef[] = [ - { field: "make" }, - { - field: "model", - cellEditor: 'agSelectCellEditor', - singleClickEdit: true, - cellEditorParams: { - values: ['English', 'Spanish', 'French', 'Portuguese', '(other)'], - } - }, - { field: "price", type: 'number' - // cellEditor: 'agDateCellEditor', - // cellEditorParams: { - // min: '2000-01-01', - // max: '2019-12-31', - // } - }, - { field: "electric", editable: true } - ]; + } diff --git a/client/src/environments/environment.development.ts b/client/src/environments/environment.development.ts deleted file mode 100644 index c3d6285..0000000 --- a/client/src/environments/environment.development.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const environment = { - location: 'http://localhost:4200' -}; diff --git a/client/src/environments/environment.prod.ts b/client/src/environments/environment.prod.ts new file mode 100644 index 0000000..5f02542 --- /dev/null +++ b/client/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + location: 'https://keyvaultpro.de' +}; diff --git a/client/src/environments/environment.ts b/client/src/environments/environment.ts index 5f02542..c3d6285 100644 --- a/client/src/environments/environment.ts +++ b/client/src/environments/environment.ts @@ -1,3 +1,3 @@ export const environment = { - location: 'https://keyvaultpro.de' + location: 'http://localhost:4200' };