From a2e6243e93d703fcc9400af3775b61e2d1c1378c Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Tue, 18 Feb 2025 18:05:51 -0600 Subject: [PATCH] change to firebase auth --- bizmatch-server/.gitignore | 1 + bizmatch-server/.vscode/launch.json | 4 +- bizmatch-server/src/app.module.ts | 3 +- bizmatch/package.json | 1 + bizmatch/src/app/app.component.html | 2 +- bizmatch/src/app/app.config.ts | 8 ++ bizmatch/src/app/app.routes.ts | 12 +- .../email-verification.component.html | 7 + .../email-verification.component.ts | 9 ++ .../components/footer/footer.component.html | 2 +- .../components/header/header.component.html | 4 +- .../app/components/header/header.component.ts | 5 +- .../login-register.component.html | 51 +++++++ .../login-register.component.ts | 85 ++++++++++++ .../app/components/logout/logout.component.ts | 11 +- bizmatch/src/app/guards/auth.guard.ts | 70 ++++++---- .../src/app/interceptors/auth.interceptor.ts | 25 ++++ .../details-business-listing.component.ts | 5 +- ...s-commercial-property-listing.component.ts | 5 +- .../details-user/details-user.component.ts | 5 +- .../src/app/pages/home/home.component.html | 5 +- bizmatch/src/app/pages/home/home.component.ts | 5 +- .../src/app/pages/login/login.component.ts | 13 +- .../app/pages/pricing/pricing.component.ts | 5 +- .../subscription/account/account.component.ts | 5 +- .../edit-business-listing.component.ts | 5 +- ...t-commercial-property-listing.component.ts | 5 +- .../email-us/email-us.component.ts | 5 +- .../favorites/favorites.component.ts | 12 +- .../my-listing/my-listing.component.ts | 5 +- .../app/pages/success/success.component.ts | 6 +- bizmatch/src/app/services/auth.service.ts | 131 ++++++++++++++++++ bizmatch/src/app/utils/utils.ts | 2 +- bizmatch/src/environments/environment.base.ts | 9 ++ 34 files changed, 465 insertions(+), 63 deletions(-) create mode 100644 bizmatch/src/app/components/email-verification/email-verification.component.html create mode 100644 bizmatch/src/app/components/email-verification/email-verification.component.ts create mode 100644 bizmatch/src/app/components/login-register/login-register.component.html create mode 100644 bizmatch/src/app/components/login-register/login-register.component.ts create mode 100644 bizmatch/src/app/interceptors/auth.interceptor.ts create mode 100644 bizmatch/src/app/services/auth.service.ts diff --git a/bizmatch-server/.gitignore b/bizmatch-server/.gitignore index 68cb476..377b11e 100644 --- a/bizmatch-server/.gitignore +++ b/bizmatch-server/.gitignore @@ -58,6 +58,7 @@ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json pictures pictures_base +pictures_ src/*.js bun.lockb diff --git a/bizmatch-server/.vscode/launch.json b/bizmatch-server/.vscode/launch.json index 1a645a2..fb9a8e7 100644 --- a/bizmatch-server/.vscode/launch.json +++ b/bizmatch-server/.vscode/launch.json @@ -20,10 +20,10 @@ { "type": "node", "request": "launch", - "name": "Launch TypeScript file with tsx", + "name": "Launch import from exported with tsx", "runtimeExecutable": "npx", "runtimeArgs": ["tsx", "--inspect"], - "args": ["${workspaceFolder}/src/drizzle/import.ts"], + "args": ["${workspaceFolder}/src/drizzle/importFromExported.ts"], "cwd": "${workspaceFolder}", "outFiles": ["${workspaceFolder}/dist/**/*.js", "!**/node_modules/**"], "sourceMaps": true, diff --git a/bizmatch-server/src/app.module.ts b/bizmatch-server/src/app.module.ts index b40aec7..928533f 100644 --- a/bizmatch-server/src/app.module.ts +++ b/bizmatch-server/src/app.module.ts @@ -23,7 +23,6 @@ import { APP_INTERCEPTOR } from '@nestjs/core'; import { ClsMiddleware, ClsModule } from 'nestjs-cls'; import { LoggingInterceptor } from './interceptors/logging.interceptor'; import { UserInterceptor } from './interceptors/user.interceptor'; -import { PaymentModule } from './payment/payment.module'; import { RequestDurationMiddleware } from './request-duration/request-duration.middleware'; import { SelectOptionsModule } from './select-options/select-options.module'; import { UserModule } from './user/user.module'; @@ -70,7 +69,7 @@ console.log(JSON.stringify(process.env, null, 2)); PassportModule, AiModule, LogModule, - PaymentModule, + // PaymentModule, EventModule, ], controllers: [AppController, LogController], diff --git a/bizmatch/package.json b/bizmatch/package.json index 5cf23a8..4b88f19 100644 --- a/bizmatch/package.json +++ b/bizmatch/package.json @@ -18,6 +18,7 @@ "@angular/common": "^18.1.3", "@angular/compiler": "^18.1.3", "@angular/core": "^18.1.3", + "@angular/fire": "^18.0.1", "@angular/forms": "^18.1.3", "@angular/platform-browser": "^18.1.3", "@angular/platform-browser-dynamic": "^18.1.3", diff --git a/bizmatch/src/app/app.component.html b/bizmatch/src/app/app.component.html index cefdb7c..0523329 100644 --- a/bizmatch/src/app/app.component.html +++ b/bizmatch/src/app/app.component.html @@ -1,6 +1,6 @@
- @if (actualRoute !=='home'){ + @if (actualRoute !=='home' && actualRoute !=='login'){
}
diff --git a/bizmatch/src/app/app.config.ts b/bizmatch/src/app/app.config.ts index 894734a..72eb61b 100644 --- a/bizmatch/src/app/app.config.ts +++ b/bizmatch/src/app/app.config.ts @@ -2,6 +2,8 @@ import { APP_INITIALIZER, ApplicationConfig, ErrorHandler } from '@angular/core' import { provideRouter, withEnabledBlockingInitialNavigation, withInMemoryScrolling } from '@angular/router'; import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; +import { initializeApp, provideFirebaseApp } from '@angular/fire/app'; +import { getAuth, provideAuth } from '@angular/fire/auth'; import { provideAnimations } from '@angular/platform-browser/animations'; import { KeycloakBearerInterceptor, KeycloakService } from 'keycloak-angular'; import { GALLERY_CONFIG, GalleryConfig } from 'ng-gallery'; @@ -9,7 +11,9 @@ import { provideQuillConfig } from 'ngx-quill'; import { provideShareButtonsOptions, SharerMethods, withConfig } from 'ngx-sharebuttons'; import { shareIcons } from 'ngx-sharebuttons/icons'; import { provideNgxStripe } from 'ngx-stripe'; +import { environment } from '../environments/environment'; import { routes } from './app.routes'; +import { AuthInterceptor } from './interceptors/auth.interceptor'; import { LoadingInterceptor } from './interceptors/loading.interceptor'; import { TimeoutInterceptor } from './interceptors/timeout.interceptor'; import { GlobalErrorHandler } from './services/globalErrorHandler'; @@ -52,6 +56,7 @@ export const appConfig: ApplicationConfig = { useClass: TimeoutInterceptor, multi: true, }, + { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }, { provide: 'TIMEOUT_DURATION', useValue: 5000, // Standard-Timeout von 5 Sekunden @@ -93,6 +98,9 @@ export const appConfig: ApplicationConfig = { ], }, }), + provideFirebaseApp(() => initializeApp(environment.firebaseConfig)), + provideAuth(() => getAuth()), + // provideFirestore(() => getFirestore()), ], }; function initServices(selectOptions: SelectOptionsService) { diff --git a/bizmatch/src/app/app.routes.ts b/bizmatch/src/app/app.routes.ts index dbf83a5..b4f912c 100644 --- a/bizmatch/src/app/app.routes.ts +++ b/bizmatch/src/app/app.routes.ts @@ -2,6 +2,7 @@ import { Routes } from '@angular/router'; import { LogoutComponent } from './components/logout/logout.component'; import { NotFoundComponent } from './components/not-found/not-found.component'; +import { LoginRegisterComponent } from './components/login-register/login-register.component'; import { AuthGuard } from './guards/auth.guard'; import { ListingCategoryGuard } from './guards/listing-category.guard'; import { UserListComponent } from './pages/admin/user-list/user-list.component'; @@ -12,7 +13,6 @@ import { HomeComponent } from './pages/home/home.component'; import { BrokerListingsComponent } from './pages/listings/broker-listings/broker-listings.component'; import { BusinessListingsComponent } from './pages/listings/business-listings/business-listings.component'; import { CommercialPropertyListingsComponent } from './pages/listings/commercial-property-listings/commercial-property-listings.component'; -import { LoginComponent } from './pages/login/login.component'; import { PricingComponent } from './pages/pricing/pricing.component'; import { AccountComponent } from './pages/subscription/account/account.component'; import { EditBusinessListingComponent } from './pages/subscription/edit-business-listing/edit-business-listing.component'; @@ -57,9 +57,17 @@ export const routes: Routes = [ canActivate: [ListingCategoryGuard], component: NotFoundComponent, // Dummy-Komponente, wird nie angezeigt, da der Guard weiterleitet }, + // { + // path: 'login/:page', + // component: LoginComponent, // Dummy-Komponente, wird nie angezeigt, da der Guard weiterleitet + // }, { path: 'login/:page', - component: LoginComponent, // Dummy-Komponente, wird nie angezeigt, da der Guard weiterleitet + component: LoginRegisterComponent, // Dummy-Komponente, wird nie angezeigt, da der Guard weiterleitet + }, + { + path: 'login', + component: LoginRegisterComponent, // Dummy-Komponente, wird nie angezeigt, da der Guard weiterleitet }, { path: 'notfound', diff --git a/bizmatch/src/app/components/email-verification/email-verification.component.html b/bizmatch/src/app/components/email-verification/email-verification.component.html new file mode 100644 index 0000000..9187aa7 --- /dev/null +++ b/bizmatch/src/app/components/email-verification/email-verification.component.html @@ -0,0 +1,7 @@ +
+
+

Email Verification

+

A verification email has been sent to your email address. Please check your inbox and click the link to verify your account.

+

Once verified, please return to the application.

+
+
diff --git a/bizmatch/src/app/components/email-verification/email-verification.component.ts b/bizmatch/src/app/components/email-verification/email-verification.component.ts new file mode 100644 index 0000000..79f44b7 --- /dev/null +++ b/bizmatch/src/app/components/email-verification/email-verification.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-email-verification', + standalone: true, + imports: [], + templateUrl: './email-verification.component.html', +}) +export class EmailVerificationComponent {} diff --git a/bizmatch/src/app/components/footer/footer.component.html b/bizmatch/src/app/components/footer/footer.component.html index 28ceb87..4d6f7fe 100644 --- a/bizmatch/src/app/components/footer/footer.component.html +++ b/bizmatch/src/app/components/footer/footer.component.html @@ -11,7 +11,7 @@
diff --git a/bizmatch/src/app/components/header/header.component.html b/bizmatch/src/app/components/header/header.component.html index ee22834..7943e2b 100644 --- a/bizmatch/src/app/components/header/header.component.html +++ b/bizmatch/src/app/components/header/header.component.html @@ -135,10 +135,10 @@