From 4e4508168ee0f67d51cde12445a0f73bec1a8893 Mon Sep 17 00:00:00 2001 From: Dimitri DI GUSTO <dimitri.digusto@ausy.fr> Date: Wed, 10 Feb 2021 17:28:54 +0100 Subject: [PATCH] WIP: debug SSR app --- src/app/app-config.module.ts | 114 ++++++++++++++++++ src/app/app.component.ts | 10 +- src/app/app.module.ts | 52 ++++---- .../components/feedback/feedback.component.ts | 18 ++- .../main/footer/footer.component.ts | 14 ++- .../main/side-menu/side-menu.component.ts | 26 ++-- src/app/core/services/app-config.service.ts | 4 +- .../resources-queryable.component.ts | 13 +- .../guards/credits-activated.guard.ts | 11 +- .../guards/partners-activated.guard.ts | 11 +- .../guards/reuses-activated.guard.ts | 11 +- .../services/elasticsearch.service.ts | 13 +- src/app/user/services/user.service.ts | 30 ++--- 13 files changed, 236 insertions(+), 91 deletions(-) create mode 100644 src/app/app-config.module.ts diff --git a/src/app/app-config.module.ts b/src/app/app-config.module.ts new file mode 100644 index 00000000..f39c3eb2 --- /dev/null +++ b/src/app/app-config.module.ts @@ -0,0 +1,114 @@ +import { NgModule, InjectionToken } from '@angular/core'; +import { environment } from '../environments/environment'; +import configJson from '../assets/config/config.json'; + +export let APP_CONFIG = new InjectionToken<AppConfig>('app.config'); + +class License { + matchingKeys: string[]; + nameFr: string; + nameEn: string; + acronymFr: string; + acronymEn: string; + url: string; +} + +export class AppConfig { + baseUrl: string; + backendUrls: { + organizations: string; + resources: string; + credits: string; + changelog: string; + auth: string; + middlewareLegacyAuth: string; + email: string; + matomo: string; + elasticsearch: string; + catalogue: string; + reuses: string; + geocoder: string; + proxyQuery: string; + seo: string; + datasetUsageStatistics: string; + }; + layer3d: { + url: string; + }; + theFunctionalitiesInterruptor: { + credits: boolean; + reuses: boolean; + partners: boolean; + }; + licenses: License[]; +} + +export const APP_DI_CONFIG: AppConfig = { + baseUrl: 'http://localhost:4200/', + backendUrls: { + organizations: 'https://preprod.data.beta.grandlyon.com/api/organizations', + resources: 'https://preprod.data.beta.grandlyon.com/api/resources', + changelog: 'https://preprod.data.beta.grandlyon.com/api/changelog', + credits: 'https://preprod.data.beta.grandlyon.com/api/credits/credits', + auth: 'https://preprod.data.beta.grandlyon.com/api/authentication/', + middlewareLegacyAuth: 'https://preprod.data.beta.grandlyon.com/api/legacy-auth-middleware/', + email: 'https://preprod.data.beta.grandlyon.com/api/email', + matomo: 'https://preprod.data.beta.grandlyon.com/api/analytics/pageStats', + elasticsearch: 'https://preprod.data.beta.grandlyon.com/api/elasticsearch', + catalogue: 'https://preprod.data.beta.grandlyon.com/api/csv-catalog-download', + reuses: 'https://preprod.data.beta.grandlyon.com/api/reuses', + proxyQuery: 'https://preprod.data.beta.grandlyon.com/api/query', + geocoder: 'https://download.data.grandlyon.com/geocoding/photon', + datasetUsageStatistics: 'https://download.data.grandlyon.com/statistiques/dataset', + seo: '/share', + }, + layer3d: { + url: 'https://data-reloaded-dev.alpha.grandlyon.com/api/query/map/mvt/grandlyon?LAYERS=fpc_fond_plan_communaut.fpctoit&map.imagetype=mvt&tilemode=gmap&tile={x}+{y}+{z}&mode=tile' + }, + theFunctionalitiesInterruptor: { + credits: true, + reuses: true, + partners: true, + }, + licenses: [ + { + matchingKeys: [ + 'Licence Ouverte', + ], + nameFr: 'Licence Ouverte', + nameEn: 'Open License', + acronymFr: 'Licence Ouverte', + acronymEn: 'Open License', + url: 'https://download.data.grandlyon.com/licences/ETALAB-Licence-Ouverte-v2.0.pdf', + }, + { + matchingKeys: [ + 'Licence ODbL', + 'licence ODBL', + ], + nameFr: 'Licence ODbL', + nameEn: 'Open Database License', + acronymFr: 'Licence ODbL', + acronymEn: 'License ODbL', + url: 'https://download.data.grandlyon.com/licences/odbl.pdf', + }, + { + matchingKeys: [ + 'Licence de réutilisation des données d\'intérêt général', + ], + nameFr: 'Licence de Réutilisation des Données d\'Intérêt Général', + nameEn: 'General Interest Data Reuse License', + acronymFr: 'Licence LRDIG', + acronymEn: 'License LRDIG', + url: 'https://download.data.grandlyon.com/licences/Licence_Reutilisation_Donnees_Interet_General.pdf', + }, + ], +}; + +@NgModule({ + providers: [{ + provide: APP_CONFIG, + useValue: APP_DI_CONFIG, + }], +}) +export class AppConfigModule { } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 552fafd8..97439110 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,11 +1,12 @@ import { Component, OnInit, Inject, PLATFORM_ID } from '@angular/core'; -import { Title } from '@angular/platform-browser'; +import { Title, Meta, MetaDefinition } from '@angular/platform-browser'; import { Angulartics2Piwik } from 'angulartics2/piwik'; import { filter, map } from 'rxjs/operators'; import { ActivatedRoute, NavigationEnd, Router } from '../../node_modules/@angular/router'; import { environment } from '../environments/environment'; import { NavigationHistoryService } from './core/services'; import { AppRoutes } from './routes'; +import { isPlatformBrowser } from '@angular/common'; @Component({ selector: 'app-root', @@ -36,7 +37,12 @@ export class AppComponent implements OnInit { filter(event => event instanceof NavigationEnd), map(() => this._activatedRoute.snapshot), map((route) => { - const lang = window.location.href.includes(environment.angularAppHost.en) ? 'en' : 'fr'; + let lang; + if (isPlatformBrowser(this._platformId)) { + lang = window.location.href.includes(environment.angularAppHost.en) ? 'en' : 'fr'; + } else { + lang = 'fr'; + } let r = route; const titles = [AppRoutes.root.title[lang]]; while (r.firstChild) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 65d4f482..4504f055 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,8 +1,7 @@ import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { NgModule, APP_INITIALIZER } from '@angular/core'; +import { NgModule, APP_INITIALIZER, PLATFORM_ID } from '@angular/core'; import { HttpClientModule, HttpClientXsrfModule } from '@angular/common/http'; - import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; import { CoreModule } from './core/core.module'; @@ -13,33 +12,30 @@ import { UserService } from './user/services'; import { AppConfigService, NotificationService } from './core/services'; import { timeout } from 'rxjs/operators'; import { notificationMessages } from '../i18n/traductions'; +import { isPlatformBrowser } from '@angular/common'; +import { AppConfigModule } from './app-config.module'; // Function used by APP_INITIALIZER before the app start: init user info / statut (expect a promise) export function initUserService(authService: UserService, notificationService: NotificationService) { return (): Promise<any> => { return new Promise((resolve, reject) => { - authService.initializeService().pipe(timeout(3000)).subscribe( - () => { - resolve(); - }, - (err) => { - if (err.status !== 401) { - notificationService.notify({ - type: 'error', - message: notificationMessages.userInfo.userInit, - }); - } - resolve(); - }); - }); - }; -} - -export function initAppConfig(appConfigService: AppConfigService) { - return (): Promise<any> => { - return new Promise((resolve, reject) => { - appConfigService.load(); - resolve(); + if (isPlatformBrowser(authService._platformId)) { + authService.initializeService().pipe(timeout(3000)).subscribe( + () => { + resolve(); + }, + (err) => { + if (err.status !== 401) { + notificationService.notify({ + type: 'error', + message: notificationMessages.userInfo.userInit, + }); + } + resolve(); + }); + } else { + resolve(); + } }); }; } @@ -56,16 +52,10 @@ export function initAppConfig(appConfigService: AppConfigService) { EditorialisationModule, UserModule, AppRoutingModule, + AppConfigModule, Angulartics2Module.forRoot(), ], providers: [ - // The order is important as the InitUserService require the configuration of the app - { - provide: APP_INITIALIZER, - useFactory: initAppConfig, - deps: [AppConfigService], - multi: true, - }, { provide: APP_INITIALIZER, useFactory: initUserService, diff --git a/src/app/core/components/feedback/feedback.component.ts b/src/app/core/components/feedback/feedback.component.ts index 49ad24e5..f7725a55 100644 --- a/src/app/core/components/feedback/feedback.component.ts +++ b/src/app/core/components/feedback/feedback.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, Inject, OnInit, PLATFORM_ID} from '@angular/core'; import { EmailService, NotificationService, AppStateService } from '../../services'; import { environment } from '../../../../environments/environment'; import { Feedback, Notification } from '../../models'; @@ -6,6 +6,8 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { notificationMessages, feedback } from '../../../../i18n/traductions'; import { Router, NavigationEnd, NavigationStart } from '@angular/router'; import { AppRoutes } from '../../../routes'; +import { isPlatformBrowser } from '@angular/common'; +import {APP_CONFIG} from "../../services/app-config.service"; @Component({ selector: 'app-feedback', @@ -27,13 +29,14 @@ export class FeedbackComponent implements OnInit { private _notificationService: NotificationService, private _fb: FormBuilder, private _router: Router, + @Inject(PLATFORM_ID) private _platformId, ) { this.isExpended = this._appStateService.feedbackOpened; this.feedbackForm = this._fb.group({ message: ['', [Validators.required]], feeling: [null], email: [null], - consent: [null] + consent: [null], }); } @@ -43,7 +46,7 @@ export class FeedbackComponent implements OnInit { this.isExpended = state; // Reset the var state to false after the end of the animation setTimeout(() => { this.hasBeenClicked = false; }, 500); - }) + }); this._router.events.subscribe((event) => { if (event instanceof NavigationStart) { this._appStateService.changeFeedbackState(false); @@ -80,7 +83,11 @@ export class FeedbackComponent implements OnInit { if (this.feedbackForm.valid) { const feedback = new Feedback(); - feedback.url = window.location.href; + if (isPlatformBrowser(this._platformId)) { + feedback.url = window.location.href; + } else { + feedback.url = APP_CONFIG.baseUrl; + } feedback.version = environment.version; feedback.message = this.feedbackForm.get('message').value; feedback.feeling = parseInt(this.feedbackForm.get('feeling').value, 10); @@ -120,8 +127,7 @@ export class FeedbackComponent implements OnInit { get feedbackHasEmail() { if (this.feedbackForm.get('email').value !== null && this.feedbackForm.get('email').value !== '') { return true; - } - else { + } else { return false; } } diff --git a/src/app/core/components/main/footer/footer.component.ts b/src/app/core/components/main/footer/footer.component.ts index 968bc6a6..0e511378 100644 --- a/src/app/core/components/main/footer/footer.component.ts +++ b/src/app/core/components/main/footer/footer.component.ts @@ -1,7 +1,7 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; import { AppRoutes } from '../../../../routes'; import { AppStateService } from '../../../services'; -import { APP_CONFIG } from '../../../services/app-config.service'; +import { APP_CONFIG, AppConfig } from '../../../../app-config.module'; @Component({ selector: 'app-footer', @@ -11,12 +11,16 @@ import { APP_CONFIG } from '../../../services/app-config.service'; export class FooterComponent implements OnInit { // Instanciate the object containing routes name AppRoutes = AppRoutes; - APP_CONFIG = APP_CONFIG; - catalogueUrl = APP_CONFIG.backendUrls.catalogue; + APP_CONFIG; + catalogueUrl; constructor( private _appStateService: AppStateService, - ) { } + @Inject(APP_CONFIG) private _appConfig: AppConfig, + ) { + this.APP_CONFIG = this._appConfig; + this.catalogueUrl = this._appConfig.backendUrls.catalogue; + } ngOnInit() { } diff --git a/src/app/core/components/main/side-menu/side-menu.component.ts b/src/app/core/components/main/side-menu/side-menu.component.ts index 85bd9a74..3aeaf64c 100644 --- a/src/app/core/components/main/side-menu/side-menu.component.ts +++ b/src/app/core/components/main/side-menu/side-menu.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, Inject, Input, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core'; import { NavigationEnd, NavigationStart, Router } from '@angular/router'; import { Subscription } from 'rxjs'; import { environment } from '../../../../../environments/environment'; @@ -6,7 +6,8 @@ import { ElasticsearchService } from '../../../../elasticsearch/services/elastic import { AppRoutes } from '../../../../routes'; import { UserService } from '../../../../user/services'; import { AppStateService } from '../../../services'; -import { APP_CONFIG } from '../../../services/app-config.service'; +import { APP_CONFIG, AppConfig } from '../../../../app-config.module'; +import { isPlatformBrowser } from '@angular/common'; @Component({ selector: 'app-side-menu', @@ -18,7 +19,7 @@ export class SideMenuComponent implements OnInit, OnDestroy { @Input() isOpened: boolean; AppRoutes = AppRoutes; - APP_CONFIG = APP_CONFIG; + APP_CONFIG; env = environment; isHomePage: boolean; displayAdminBar = false; @@ -32,7 +33,11 @@ export class SideMenuComponent implements OnInit, OnDestroy { private _userService: UserService, private _elasticsearchService: ElasticsearchService, private _appStateService: AppStateService, - ) { } + @Inject(PLATFORM_ID) private _plateformId, + @Inject(APP_CONFIG) private _appConfig: AppConfig, + ) { + this.APP_CONFIG = this._appConfig; + } ngOnInit() { this.burgerStatus = false; @@ -76,13 +81,18 @@ export class SideMenuComponent implements OnInit, OnDestroy { } changeLanguage(lang: string) { - window.location.href = environment.angularAppHost[lang] + this._router.url; + if (isPlatformBrowser(this._plateformId)) { + window.location.href = environment.angularAppHost[lang] + this._router.url; + } } currentLanguage() { - return window.location.href.includes(environment.angularAppHost.en) ? - environment.angularAppHost.en : - environment.angularAppHost.fr; + if (isPlatformBrowser(this._plateformId)) { + return window.location.href.includes(environment.angularAppHost.en) ? + environment.angularAppHost.en : + environment.angularAppHost.fr; + } + return environment.angularAppHost.fr; } signOut() { diff --git a/src/app/core/services/app-config.service.ts b/src/app/core/services/app-config.service.ts index 163d920f..ade11707 100644 --- a/src/app/core/services/app-config.service.ts +++ b/src/app/core/services/app-config.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; export class AppConfig { + baseUrl: string; backendUrls: { organizations: string; resources: string; @@ -42,7 +43,6 @@ export let APP_CONFIG: AppConfig = new AppConfig(); @Injectable() export class AppConfigService { - constructor() { } public load() { @@ -52,11 +52,9 @@ export class AppConfigService { fetch('./assets/config/config.json') .then(response => response.json()) .then((config) => { - console.log(config); if (!config) { return; } - // Store the response so that your ConfigService can read it. APP_CONFIG = Object.assign(conf, config); }); diff --git a/src/app/dataset-detail/components/dataset-api/resources-queryable/resources-queryable.component.ts b/src/app/dataset-detail/components/dataset-api/resources-queryable/resources-queryable.component.ts index 2f04c318..e5b717a4 100644 --- a/src/app/dataset-detail/components/dataset-api/resources-queryable/resources-queryable.component.ts +++ b/src/app/dataset-detail/components/dataset-api/resources-queryable/resources-queryable.component.ts @@ -1,8 +1,9 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Inject, Input, OnInit, PLATFORM_ID } from '@angular/core'; import { environment } from '../../../../../environments/environment'; import { Metadata } from '../../../../shared/models'; import { Projection, Resource } from '../../../models'; import { ResourcesService } from '../../../services'; +import { isPlatformBrowser } from '@angular/common'; @Component({ selector: 'app-resources-queryable', @@ -18,6 +19,7 @@ export class ResourcesQueryableComponent implements OnInit { constructor( private _resourcesService: ResourcesService, + @Inject(PLATFORM_ID) private _platformId, ) { } @@ -37,8 +39,11 @@ export class ResourcesQueryableComponent implements OnInit { } getMessageWarning(resource: Resource) { - return window.location.href.includes(environment.angularAppHost.en) ? - resource.messageWarningEn : - resource.messageWarningFr; + if (isPlatformBrowser(this._platformId)) { + return window.location.href.includes(environment.angularAppHost.en) ? + resource.messageWarningEn : + resource.messageWarningFr; + } + return resource.messageWarningFr; } } diff --git a/src/app/editorialisation/guards/credits-activated.guard.ts b/src/app/editorialisation/guards/credits-activated.guard.ts index 9d931c97..4c49c7e0 100644 --- a/src/app/editorialisation/guards/credits-activated.guard.ts +++ b/src/app/editorialisation/guards/credits-activated.guard.ts @@ -1,15 +1,18 @@ -import { Injectable } from '@angular/core'; +import {Inject, Injectable} from '@angular/core'; import { Router, CanActivate } from '@angular/router'; import { AppRoutes } from '../../routes'; -import { APP_CONFIG } from '../../core/services/app-config.service'; +import { APP_CONFIG, AppConfig } from '../../app-config.module'; @Injectable() export class CreditsActivatedGuard implements CanActivate { - constructor(public router: Router) { } + constructor( + public router: Router, + @Inject(APP_CONFIG) private _appConfig: AppConfig, + ) { } canActivate(): boolean { - if (!APP_CONFIG.theFunctionalitiesInterruptor.credits) { + if (!this._appConfig.theFunctionalitiesInterruptor.credits) { this.router.navigate(['/', AppRoutes.page404.uri]); return false; } diff --git a/src/app/editorialisation/guards/partners-activated.guard.ts b/src/app/editorialisation/guards/partners-activated.guard.ts index 180804e2..017cfed7 100644 --- a/src/app/editorialisation/guards/partners-activated.guard.ts +++ b/src/app/editorialisation/guards/partners-activated.guard.ts @@ -1,15 +1,18 @@ -import { Injectable } from '@angular/core'; +import {Inject, Injectable} from '@angular/core'; import { Router, CanActivate } from '@angular/router'; import { AppRoutes } from '../../routes'; -import { APP_CONFIG } from '../../core/services/app-config.service'; +import { APP_CONFIG, AppConfig } from '../../app-config.module'; @Injectable() export class PartnersActivatedGuard implements CanActivate { - constructor(public router: Router) { } + constructor( + public router: Router, + @Inject(APP_CONFIG) private _appConfig: AppConfig, + ) { } canActivate(): boolean { - if (!APP_CONFIG.theFunctionalitiesInterruptor.partners) { + if (!this._appConfig.theFunctionalitiesInterruptor.partners) { this.router.navigate(['/', AppRoutes.page404.uri]); return false; } diff --git a/src/app/editorialisation/guards/reuses-activated.guard.ts b/src/app/editorialisation/guards/reuses-activated.guard.ts index 1f00ef94..e907db36 100644 --- a/src/app/editorialisation/guards/reuses-activated.guard.ts +++ b/src/app/editorialisation/guards/reuses-activated.guard.ts @@ -1,15 +1,18 @@ -import { Injectable } from '@angular/core'; +import {Inject, Injectable} from '@angular/core'; import { Router, CanActivate } from '@angular/router'; import { AppRoutes } from '../../routes'; -import { APP_CONFIG } from '../../core/services/app-config.service'; +import { APP_CONFIG, AppConfig } from '../../app-config.module'; @Injectable() export class ReusesActivatedGuard implements CanActivate { - constructor(public router: Router) { } + constructor( + public router: Router, + @Inject(APP_CONFIG) private _appConfig: AppConfig, + ) { } canActivate(): boolean { - if (!APP_CONFIG.theFunctionalitiesInterruptor.reuses) { + if (!this._appConfig.theFunctionalitiesInterruptor.reuses) { this.router.navigate(['/', AppRoutes.page404.uri]); return false; } diff --git a/src/app/elasticsearch/services/elasticsearch.service.ts b/src/app/elasticsearch/services/elasticsearch.service.ts index 62e429c3..c3e603dc 100644 --- a/src/app/elasticsearch/services/elasticsearch.service.ts +++ b/src/app/elasticsearch/services/elasticsearch.service.ts @@ -1,10 +1,10 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Inject, Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { geosource, notificationMessages } from '../../../i18n/traductions'; -import { ErrorService } from '../../core/services'; -import { APP_CONFIG } from '../../core/services/app-config.service'; +import { AppConfigService, ErrorService } from '../../core/services'; +import { APP_CONFIG, AppConfig } from '../../app-config.module'; import { scopesResearch } from '../../shared/variables'; import { Aggregation, ElasticsearchOptions, Filter, IElasticsearchResponse, IPostsESOptions } from '../models'; @@ -23,14 +23,15 @@ export class ElasticsearchService { constructor( private _errorService: ErrorService, private _http: HttpClient, + private _appConfigService: AppConfigService, + @Inject(APP_CONFIG) private _appConfig: AppConfig, ) { - this.elasticSearchUrl = `${APP_CONFIG.backendUrls.elasticsearch}` + - '/_search?request_cache=true'; + this.elasticSearchUrl = `${this._appConfig.backendUrls.elasticsearch}/_search?request_cache=true`; } /** * This is the main elasticsearch (ES) request to get information from ES - * We have one ES options as parameter used for multiple purposes: + * We have one ES options as parameter used for multiple purposes: * - research, sorting, paginations, highlight, etc... */ getAllEntities(options: ElasticsearchOptions): Observable<IElasticsearchResponse> { diff --git a/src/app/user/services/user.service.ts b/src/app/user/services/user.service.ts index 7cc1cf94..41ce0734 100644 --- a/src/app/user/services/user.service.ts +++ b/src/app/user/services/user.service.ts @@ -1,10 +1,10 @@ -import { Injectable } from '@angular/core'; +import { Inject, Injectable, PLATFORM_ID } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, Subject } from 'rxjs'; import { IUserInfo, PasswordUpdateForm, User, ILoginResponse, LegacyAccount, IPasswordForgottenForm } from '../models'; import { map, mergeMap, tap } from 'rxjs/operators'; import * as NodeRSA from 'node-rsa'; -import { APP_CONFIG } from '../../core/services/app-config.service'; +import { APP_CONFIG, AppConfig } from '../../app-config.module'; @Injectable() export class UserService { @@ -14,6 +14,8 @@ export class UserService { constructor( private _http: HttpClient, + @Inject(PLATFORM_ID) public _platformId, + @Inject(APP_CONFIG) private _appConfig: AppConfig, ) { this._userStatusChangedSubject = new Subject<boolean>(); } @@ -71,7 +73,7 @@ export class UserService { ), mergeMap(() => { return this._http.post<ILoginResponse>( - `${APP_CONFIG.backendUrls.auth}login/legacy`, + `${this._appConfig.backendUrls.auth}login/legacy`, form, { withCredentials: true }, ); @@ -85,7 +87,7 @@ export class UserService { } logout(): Observable<boolean> { - return this._http.get<boolean>(`${APP_CONFIG.backendUrls.auth}logout`, { withCredentials: true }); + return this._http.get<boolean>(`${this._appConfig.backendUrls.auth}logout`, { withCredentials: true }); } createAccount(legacyAccount: LegacyAccount): Observable<boolean> { @@ -98,7 +100,7 @@ export class UserService { }, ), mergeMap(() => { - return this._http.post<any>(`${APP_CONFIG.backendUrls.middlewareLegacyAuth}user/`, form); + return this._http.post<any>(`${this._appConfig.backendUrls.middlewareLegacyAuth}user/`, form); }), map( (res) => { @@ -109,16 +111,16 @@ export class UserService { } validateAccount(token: string) { - return this._http.post<any>(`${APP_CONFIG.backendUrls.middlewareLegacyAuth}user/validateAccount`, { token }); + return this._http.post<any>(`${this._appConfig.backendUrls.middlewareLegacyAuth}user/validateAccount`, { token }); } getUserInfo(): Observable<IUserInfo> { - return this._http.get<IUserInfo>(`${APP_CONFIG.backendUrls.auth}user`, { withCredentials: true }); + return this._http.get<IUserInfo>(`${this._appConfig.backendUrls.auth}user`, { withCredentials: true }); } updateUserInfo(info: IUserInfo): Observable<{ token: string }> { return this._http.put<{ token: string }>( - `${APP_CONFIG.backendUrls.auth}user/update`, + `${this._appConfig.backendUrls.auth}user/update`, info, { withCredentials: true }, ); @@ -136,7 +138,7 @@ export class UserService { ), mergeMap(() => { return this._http.put<void>( - `${APP_CONFIG.backendUrls.middlewareLegacyAuth}user/updatePassword`, + `${this._appConfig.backendUrls.middlewareLegacyAuth}user/updatePassword`, form, { withCredentials: true }, ); @@ -145,7 +147,7 @@ export class UserService { } forgotPassword(email: IPasswordForgottenForm): Observable<void> { - return this._http.post<void>(`${APP_CONFIG.backendUrls.middlewareLegacyAuth}passwordForgotten`, email).pipe( + return this._http.post<void>(`${this._appConfig.backendUrls.middlewareLegacyAuth}passwordForgotten`, email).pipe( map( (res) => { return; @@ -156,7 +158,7 @@ export class UserService { isPasswordResetTokenValid(token: string): Observable<boolean> { // tslint:disable-next-line:max-line-length - return this._http.get<boolean>(`${APP_CONFIG.backendUrls.middlewareLegacyAuth}isPasswordResetTokenValid?token=${token}`); + return this._http.get<boolean>(`${this._appConfig.backendUrls.middlewareLegacyAuth}isPasswordResetTokenValid?token=${token}`); } resetPassword(token: string, password: string): Observable<void> { @@ -171,7 +173,7 @@ export class UserService { mergeMap(() => { // tslint:disable-next-line:max-line-length return this._http.put<void>( - `${APP_CONFIG.backendUrls.middlewareLegacyAuth}user/resetPassword`, + `${this._appConfig.backendUrls.middlewareLegacyAuth}user/resetPassword`, { token, password: encryptedPassword }, { withCredentials: true }, ); @@ -180,7 +182,7 @@ export class UserService { } deleteAccount(): Observable<void> { - return this._http.delete<any>(`${APP_CONFIG.backendUrls.middlewareLegacyAuth}user`, { withCredentials: true }).pipe( + return this._http.delete<any>(`${this._appConfig.backendUrls.middlewareLegacyAuth}user`, { withCredentials: true }).pipe( map( (res) => { return; @@ -190,7 +192,7 @@ export class UserService { } getPublicKey(): Observable<any> { - return this._http.get<any>(`${APP_CONFIG.backendUrls.middlewareLegacyAuth}publicKey`).pipe( + return this._http.get<any>(`${this._appConfig.backendUrls.middlewareLegacyAuth}publicKey`).pipe( map( (res) => { return res.publicKey; -- GitLab