environment

This commit is contained in:
Bastian Wagner
2024-09-13 21:42:05 +02:00
parent d552bd0c09
commit 00d5498e00
11 changed files with 43 additions and 70 deletions

View File

@@ -22,6 +22,7 @@ export class AuthController {
@Body() authDto: AuthCodeDto,
): Promise<User> {
const user = await this.authService.registerOrLoginWithAuthCode(authDto);
console.log(user)
if (user == null) {
throw new HttpException('forbidden', HttpStatus.FORBIDDEN);
}

View File

@@ -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;

View File

@@ -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"

View File

@@ -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<IUser>('/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<IUser>('/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);
}
})
})
}

View File

@@ -2,11 +2,8 @@
<button mat-icon-button (click)="drawer.toggle()">
<mat-icon>menu</mat-icon>
</button>
<span>Keyvault</span>
<span class="example-spacer"></span>
<button mat-icon-button class="example-icon favorite-icon" aria-label="Example icon-button with heart icon">
<mat-icon>favorite</mat-icon>
</button>
<span routerLink="/" class="logo">Keyvault</span>
<span class="spacer"></span>
<button mat-icon-button (click)="logout()">
<mat-icon>logout</mat-icon>
</button>
@@ -14,7 +11,8 @@
<mat-drawer-container class="example-container" autosize>
<mat-drawer #drawer class="main_sidenav" mode="side" opened="true">
sdf
<button mat-button routerLink="/">Home</button>
<button mat-button routerLink="/users">Alle User</button>
</mat-drawer>

View File

@@ -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%;
}
}

View File

@@ -1,7 +0,0 @@
<ag-grid-angular
style="width: 100%; height: 100%;"
[rowData]="rowData"
[columnDefs]="colDefs"
[defaultColDef]="defaultColDef"
/>

View File

@@ -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 }
];
}

View File

@@ -1,3 +0,0 @@
export const environment = {
location: 'http://localhost:4200'
};

View File

@@ -0,0 +1,3 @@
export const environment = {
location: 'https://keyvaultpro.de'
};

View File

@@ -1,3 +1,3 @@
export const environment = {
location: 'https://keyvaultpro.de'
location: 'http://localhost:4200'
};