diff --git a/.talismanrc b/.talismanrc index acfd7fad2f..2737ddb368 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,16 +1,18 @@ fileignoreconfig: - filename: _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql - checksum: 104c8036ca644bc51bb4c797e56b3a5b178a55b1c293a77308844e54ca7c404d + checksum: 8c3fbddbda155e81d1ce861dfa05c391c60199d539272d4013b71ae0100648ea - filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql - checksum: 9976de417c719ab5c3bec9d4a1bafc40bfa8d4388d2dbd5da7d1ea4a11d2db75 + checksum: 88414b9693efe32632ed9eed749e3cdc4ec5e66030160941e8d9643dfc61ad7b - filename: packages/backend/src/_migrations/1699910877010-auto-migration.ts checksum: bd05dd6b68f7fe2ca36ab1180a0449878cf78f4e048d2e5979b3dbe5fba1db53 - filename: packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts - checksum: 586e3b26481d71256a1b7626956aaf9e68211dfbda527dd862a2aad075b5cc04 + checksum: 4933dc2edd58b0d9ced8906548fec306389d66a0b415b99cd29dc09fdfe76c3b - filename: packages/backend/src/interactions/services/InteractionsDeletor.service.spec.ts checksum: b66659fea19859e55afaf0ed47519f0804857e486b2ecc6b01d5ae96f1a86a0b - filename: packages/portail-usagers/src/app/modules/general/components/_static/cgu/cgu.component.html checksum: 584da8c9b8ebc95d1d996d0201e0e57cf31e05c6704104e7adacba67a7eb4dd7 +- filename: packages/portail-usagers/src/app/modules/usager-auth/services/usager-auth.service.ts + checksum: d55d8d80cec2984b300d93cedc411653bb3c49d172cfb2c66e347ad49c715634 - filename: packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.ts checksum: 189eb0e583dc89e07c097b61b59e3ee952d84b098dd0fd75bc7cd4bc71ab3fa5 - filename: yarn.lock diff --git a/_scripts/db/dumps/domifa_test.postgres.custom.gz b/_scripts/db/dumps/domifa_test.postgres.custom.gz index 3d3b2a55ee..4260b94267 100644 Binary files a/_scripts/db/dumps/domifa_test.postgres.custom.gz and b/_scripts/db/dumps/domifa_test.postgres.custom.gz differ diff --git a/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql b/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql index b61809dbcd..b353ca2607 100644 --- a/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql +++ b/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 14.9 --- Dumped by pg_dump version 14.9 +-- Dumped from database version 14.9 (Debian 14.9-1.pgdg110+1) +-- Dumped by pg_dump version 14.9 (Debian 14.9-1.pgdg110+1) SET statement_timeout = 0; SET lock_timeout = 0; @@ -255,9 +255,9 @@ e0bcefc6-f1be-4c83-ac9d-6ea47335a9c3 2021-03-15 16:53:55.740856+01 2023-09-05 23 -- Data for Name: user_usager; Type: TABLE DATA; Schema: public; Owner: - -- -COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", enabled) FROM stdin; -a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2021-11-30 15:02:07.705535+01 18 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$cmwXTghEgrGRYTkGIJlj3Owjo8YVVDXOgceAGtkgzcD2M/Tf3Dhb. $2a$10$/uFyiR8hCe8XkRe7x2fYm. t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} t -a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$u..ofvcb5t5a44N0Oriwbew6oz600aoOFzll9yl92Lx1VOb0E8o0a $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} t +COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", enabled, "acceptTerms") FROM stdin; +a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2021-11-30 15:02:07.705535+01 18 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$cmwXTghEgrGRYTkGIJlj3Owjo8YVVDXOgceAGtkgzcD2M/Tf3Dhb. $2a$10$/uFyiR8hCe8XkRe7x2fYm. t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} t \N +a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$u..ofvcb5t5a44N0Oriwbew6oz600aoOFzll9yl92Lx1VOb0E8o0a $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} t \N \. diff --git a/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql b/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql index dc93ba61ab..7a58de30e5 100644 --- a/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql +++ b/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql @@ -28,8 +28,8 @@ TRUNCATE TABLE public.usager_options_history RESTART IDENTITY CASCADE; -- PostgreSQL database dump -- --- Dumped from database version 14.9 --- Dumped by pg_dump version 14.9 +-- Dumped from database version 14.9 (Debian 14.9-1.pgdg110+1) +-- Dumped by pg_dump version 14.9 (Debian 14.9-1.pgdg110+1) SET statement_timeout = 0; SET lock_timeout = 0; @@ -281,9 +281,9 @@ e0bcefc6-f1be-4c83-ac9d-6ea47335a9c3 2021-03-15 16:53:55.740856+01 2023-09-05 23 -- Data for Name: user_usager; Type: TABLE DATA; Schema: public; Owner: - -- -COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", enabled) FROM stdin; -a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2021-11-30 15:02:07.705535+01 18 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$cmwXTghEgrGRYTkGIJlj3Owjo8YVVDXOgceAGtkgzcD2M/Tf3Dhb. $2a$10$/uFyiR8hCe8XkRe7x2fYm. t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} t -a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$u..ofvcb5t5a44N0Oriwbew6oz600aoOFzll9yl92Lx1VOb0E8o0a $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} t +COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", enabled, "acceptTerms") FROM stdin; +a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2021-11-30 15:02:07.705535+01 18 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$cmwXTghEgrGRYTkGIJlj3Owjo8YVVDXOgceAGtkgzcD2M/Tf3Dhb. $2a$10$/uFyiR8hCe8XkRe7x2fYm. t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} t \N +a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$u..ofvcb5t5a44N0Oriwbew6oz600aoOFzll9yl92Lx1VOb0E8o0a $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} t \N \. diff --git a/packages/backend/src/_migrations/1700663362619-auto-migration.ts b/packages/backend/src/_migrations/1700663362619-auto-migration.ts index 11f9c57d3a..f34ce6d4d7 100644 --- a/packages/backend/src/_migrations/1700663362619-auto-migration.ts +++ b/packages/backend/src/_migrations/1700663362619-auto-migration.ts @@ -1,12 +1,19 @@ import { MigrationInterface, QueryRunner } from "typeorm"; +import { domifaConfig } from "../config"; export class AutoMigration1700663362619 implements MigrationInterface { name = "AutoMigration1700663362619"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "user_usager" ADD "acceptTerms" TIMESTAMP WITH TIME ZONE` - ); + if ( + domifaConfig().envId === "preprod" || + domifaConfig().envId === "prod" || + domifaConfig().envId === "local" + ) { + await queryRunner.query( + `ALTER TABLE "user_usager" ADD "acceptTerms" TIMESTAMP WITH TIME ZONE` + ); + } } public async down(queryRunner: QueryRunner): Promise { diff --git a/packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts b/packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts index c026387263..1534dedca0 100644 --- a/packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts +++ b/packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts @@ -609,6 +609,7 @@ async function createTables(queryRunner: QueryRunner) { "lastPasswordResetDate" timestamptz NULL, "lastPasswordResetStructureUser" jsonb NULL, enabled bool NOT NULL DEFAULT false, + "acceptTerms" timestamptz NULL, CONSTRAINT "PK_46cd95ba6c330d680e13ce7d932" PRIMARY KEY (uuid), CONSTRAINT "UQ_07ddbb376616a6bf4ffdbb2b6d7" UNIQUE ("usagerUUID"), CONSTRAINT "UQ_547d83b925177cadc602bc7e221" UNIQUE (id), diff --git a/packages/backend/src/_portail-usager/portail-usager-login/portail-usagers-login.controller.ts b/packages/backend/src/_portail-usager/portail-usager-login/portail-usagers-login.controller.ts index 5d4ff0404a..c5ce55a65c 100644 --- a/packages/backend/src/_portail-usager/portail-usager-login/portail-usagers-login.controller.ts +++ b/packages/backend/src/_portail-usager/portail-usager-login/portail-usagers-login.controller.ts @@ -60,17 +60,15 @@ export class PortailUsagersLoginController { usagerUUID: user.usagerUUID, }); - const portailUsagerProfile: PortailUsagerProfile = { usager }; + const portailUsagerProfile: PortailUsagerProfile = { + usager, + acceptTerms: user.acceptTerms, + }; const structure = await structureRepository.findOneByOrFail({ id: user.structureId, }); - console.log({ - usagerUUID: usager.uuid, - structureId: user.structureId, - }); - const lastLogin = await userUsagerLoginRepository.save( new UserUsagerLoginTable({ usagerUUID: usager.uuid, diff --git a/packages/frontend/src/app/app.component.ts b/packages/frontend/src/app/app.component.ts index 2673d7112a..682c5b8793 100644 --- a/packages/frontend/src/app/app.component.ts +++ b/packages/frontend/src/app/app.component.ts @@ -68,11 +68,28 @@ export class AppComponent implements OnInit, OnDestroy { public matomo: MatomoTracker ) { this.apiVersion = localStorage.getItem("version"); + this.submitted = false; this.pendingNews = false; this.loading = false; this.me = null; this.initCguForm(); + this.checkMatomo(); + } + + private checkMatomo() { + if (localStorage.getItem("matomo-opted-in") === null) { + localStorage.setItem("matomo-opted-in", JSON.stringify(true)); + } + + const disableMatomo = + JSON.parse(localStorage.getItem("matomo-opted-in")) === true; + + if (!disableMatomo) { + this.matomo.optUserOut(); + } else { + localStorage.setItem("matomo-opted-in", JSON.stringify(true)); + } } private initCguForm() { diff --git a/packages/frontend/src/app/app.module.ts b/packages/frontend/src/app/app.module.ts index c67635e542..83900fc1e7 100644 --- a/packages/frontend/src/app/app.module.ts +++ b/packages/frontend/src/app/app.module.ts @@ -30,14 +30,13 @@ import { SharedModule } from "./modules/shared/shared.module"; import pkg from "../../package.json"; -import { UserIdleModule } from "angular-user-idle"; - import { createErrorHandler, init } from "@sentry/angular"; import { MATOMO_INJECTORS } from "./shared"; import { StoreModule } from "@ngrx/store"; import { _usagerReducer } from "./shared/store/ngRxAppStore.service"; import { registerLocaleData } from "@angular/common"; import localeFr from "@angular/common/locales/fr"; +import { provideUserIdleConfig } from "angular-user-idle"; const disableAnimations = !("animate" in document.documentElement) || @@ -68,13 +67,13 @@ registerLocaleData(localeFr, "fr"); NgbModule, StoreModule.forRoot({ app: _usagerReducer }), SharedModule, - UserIdleModule.forRoot({ idle: 3600, timeout: 60, ping: 20 }), MATOMO_INJECTORS, ], providers: [ AuthService, LoadingService, CustomToastService, + provideUserIdleConfig({ idle: 3600, timeout: 60, ping: 20 }), { provide: LOCALE_ID, useValue: "fr" }, { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true }, { diff --git a/packages/frontend/src/app/guards/admin.guard.ts b/packages/frontend/src/app/guards/admin.guard.ts index db5a401a02..d77bd1c925 100644 --- a/packages/frontend/src/app/guards/admin.guard.ts +++ b/packages/frontend/src/app/guards/admin.guard.ts @@ -1,12 +1,12 @@ import { Injectable } from "@angular/core"; -import { CanActivate, Router } from "@angular/router"; +import { Router } from "@angular/router"; import { Observable } from "rxjs"; import { AuthService } from "../modules/shared/services/auth.service"; import { CustomToastService } from "../modules/shared/services/custom-toast.service"; @Injectable({ providedIn: "root" }) -export class AdminGuard implements CanActivate { +export class AdminGuard { constructor( private readonly router: Router, private readonly authService: AuthService, diff --git a/packages/frontend/src/app/guards/auth.guard.ts b/packages/frontend/src/app/guards/auth.guard.ts index 4064fb9e02..2f3d7db69d 100644 --- a/packages/frontend/src/app/guards/auth.guard.ts +++ b/packages/frontend/src/app/guards/auth.guard.ts @@ -1,7 +1,6 @@ import { Injectable } from "@angular/core"; import { ActivatedRouteSnapshot, - CanActivate, Router, RouterStateSnapshot, } from "@angular/router"; @@ -12,7 +11,7 @@ import { catchError, map } from "rxjs/operators"; import { AuthService } from "../modules/shared/services/auth.service"; @Injectable({ providedIn: "root" }) -export class AuthGuard implements CanActivate { +export class AuthGuard { constructor( public router: Router, private readonly authService: AuthService diff --git a/packages/frontend/src/app/guards/can-edit-portail-usager.guard.ts b/packages/frontend/src/app/guards/can-edit-portail-usager.guard.ts index e2fe5daf23..3acf646f90 100644 --- a/packages/frontend/src/app/guards/can-edit-portail-usager.guard.ts +++ b/packages/frontend/src/app/guards/can-edit-portail-usager.guard.ts @@ -1,11 +1,11 @@ import { Injectable } from "@angular/core"; -import { CanActivate, Router } from "@angular/router"; +import { Router } from "@angular/router"; import { CustomToastService } from "../modules/shared/services/custom-toast.service"; import { Observable } from "rxjs"; import { AuthService } from "../modules/shared/services/auth.service"; @Injectable({ providedIn: "root" }) -export class CanEditPortailUsagerGuard implements CanActivate { +export class CanEditPortailUsagerGuard { constructor( private readonly router: Router, private readonly authService: AuthService, diff --git a/packages/frontend/src/app/guards/can-edit-sms.guard.ts b/packages/frontend/src/app/guards/can-edit-sms.guard.ts index edfd69ad5b..66e12e481f 100644 --- a/packages/frontend/src/app/guards/can-edit-sms.guard.ts +++ b/packages/frontend/src/app/guards/can-edit-sms.guard.ts @@ -1,11 +1,11 @@ import { Injectable } from "@angular/core"; -import { CanActivate, Router } from "@angular/router"; +import { Router } from "@angular/router"; import { Observable } from "rxjs"; import { AuthService } from "../modules/shared/services/auth.service"; import { CustomToastService } from "../modules/shared/services/custom-toast.service"; @Injectable({ providedIn: "root" }) -export class CanEditSmsGuard implements CanActivate { +export class CanEditSmsGuard { constructor( private readonly router: Router, private readonly authService: AuthService, diff --git a/packages/frontend/src/app/guards/facteur.guard.ts b/packages/frontend/src/app/guards/facteur.guard.ts index 16f3351429..2590987643 100644 --- a/packages/frontend/src/app/guards/facteur.guard.ts +++ b/packages/frontend/src/app/guards/facteur.guard.ts @@ -1,5 +1,5 @@ import { Injectable } from "@angular/core"; -import { CanActivate, Router } from "@angular/router"; +import { Router } from "@angular/router"; import { Observable } from "rxjs"; @@ -7,7 +7,7 @@ import { AuthService } from "../modules/shared/services/auth.service"; import { CustomToastService } from "../modules/shared/services/custom-toast.service"; @Injectable({ providedIn: "root" }) -export class FacteurGuard implements CanActivate { +export class FacteurGuard { constructor( private readonly router: Router, private readonly authService: AuthService, diff --git a/packages/frontend/src/app/guards/logged.guard.ts b/packages/frontend/src/app/guards/logged.guard.ts index f76c53739d..18c1573f29 100644 --- a/packages/frontend/src/app/guards/logged.guard.ts +++ b/packages/frontend/src/app/guards/logged.guard.ts @@ -1,5 +1,5 @@ import { Injectable } from "@angular/core"; -import { CanActivate, Router } from "@angular/router"; +import { Router } from "@angular/router"; import { CustomToastService } from "../modules/shared/services/custom-toast.service"; import { Observable, of } from "rxjs"; @@ -8,7 +8,7 @@ import { map } from "rxjs/operators"; import { AuthService } from "../modules/shared/services/auth.service"; @Injectable({ providedIn: "root" }) -export class LoggedGuard implements CanActivate { +export class LoggedGuard { constructor( private readonly router: Router, private readonly authService: AuthService, diff --git a/packages/frontend/src/app/guards/responsable.guard.ts b/packages/frontend/src/app/guards/responsable.guard.ts index 651fe3f1e4..3376586028 100644 --- a/packages/frontend/src/app/guards/responsable.guard.ts +++ b/packages/frontend/src/app/guards/responsable.guard.ts @@ -1,5 +1,5 @@ import { Injectable } from "@angular/core"; -import { CanActivate, Router } from "@angular/router"; +import { Router } from "@angular/router"; import { Observable } from "rxjs"; @@ -7,7 +7,7 @@ import { AuthService } from "../modules/shared/services/auth.service"; import { CustomToastService } from "../modules/shared/services/custom-toast.service"; @Injectable({ providedIn: "root" }) -export class ResponsableGuard implements CanActivate { +export class ResponsableGuard { constructor( private readonly router: Router, private readonly authService: AuthService, diff --git a/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.html b/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.html index 9aa395267f..123b9fc4c1 100644 --- a/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.html +++ b/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.html @@ -257,6 +257,24 @@

Cookies

> +
+

+ +

diff --git a/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.spec.ts b/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.spec.ts index 5d151158b3..47841db9d2 100644 --- a/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.spec.ts +++ b/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.spec.ts @@ -1,16 +1,20 @@ -import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; - +import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core"; +import { MATOMO_INJECTORS } from "../../../../../shared"; import { PolitiqueComponent } from "./politique.component"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { FormsModule } from "@angular/forms"; describe("PolitiqueComponent", () => { let component: PolitiqueComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ + beforeEach(async () => { + await TestBed.configureTestingModule({ declarations: [PolitiqueComponent], + imports: [...MATOMO_INJECTORS, FormsModule], + schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); - })); + }); beforeEach(() => { fixture = TestBed.createComponent(PolitiqueComponent); diff --git a/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.ts b/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.ts index 539223ee28..e17efe7fff 100644 --- a/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.ts +++ b/packages/frontend/src/app/modules/general/components/static-pages/politique/politique.component.ts @@ -1,14 +1,31 @@ -import { Component, OnInit } from "@angular/core"; +import { Component } from "@angular/core"; import { Title } from "@angular/platform-browser"; +import { MatomoTracker } from "ngx-matomo-client"; @Component({ selector: "app-politique", templateUrl: "./politique.component.html", }) -export class PolitiqueComponent implements OnInit { - public constructor(private readonly titleService: Title) {} +export class PolitiqueComponent { + public optedOut$: Promise; - public ngOnInit(): void { + public constructor( + private readonly titleService: Title, + private readonly tracker: MatomoTracker + ) { + this.optedOut$ = tracker.isUserOptedOut(); this.titleService.setTitle("Politique de confidentialité de DomiFa"); } + + handleChange(optOut: boolean) { + if (optOut) { + this.tracker.optUserOut(); + localStorage.setItem("matomo-opted-in", JSON.stringify(false)); + } else { + localStorage.setItem("matomo-opted-in", JSON.stringify(true)); + this.tracker.forgetUserOptOut(); + } + + this.optedOut$ = this.tracker.isUserOptedOut(); + } } diff --git a/packages/frontend/src/app/modules/usager-profil/components/_historiques/profil-historique-login-portail/profil-historique-login-portail.component.ts b/packages/frontend/src/app/modules/usager-profil/components/_historiques/profil-historique-login-portail/profil-historique-login-portail.component.ts index 907b6fc7d4..ac764dbb77 100644 --- a/packages/frontend/src/app/modules/usager-profil/components/_historiques/profil-historique-login-portail/profil-historique-login-portail.component.ts +++ b/packages/frontend/src/app/modules/usager-profil/components/_historiques/profil-historique-login-portail/profil-historique-login-portail.component.ts @@ -61,7 +61,6 @@ export class ProfilHistoriqueLoginPortailComponent this.interactionService .getLoginPortail(this.usager.ref, this.params) .subscribe((searchResults: PageResults) => { - console.log(searchResults); this.loading = false; this.interactions = searchResults.data; this.searchResults = searchResults; diff --git a/packages/frontend/src/app/modules/usager-profil/services/usager-options.service.ts b/packages/frontend/src/app/modules/usager-profil/services/usager-options.service.ts index 1e0a0c672a..bf6efaf29a 100644 --- a/packages/frontend/src/app/modules/usager-profil/services/usager-options.service.ts +++ b/packages/frontend/src/app/modules/usager-profil/services/usager-options.service.ts @@ -68,7 +68,6 @@ export class UsagerOptionsService { ) .pipe( tap((newUsager: UsagerLight) => { - console.log(newUsager); this.store.dispatch(cacheManager.updateUsager({ usager: newUsager })); }) ); diff --git a/packages/portail-usagers/src/_common/mocks/DEFAULT_USAGER.const.ts b/packages/portail-usagers/src/_common/mocks/DEFAULT_USAGER.const.ts index 721aa9a8c6..38f2e1173d 100644 --- a/packages/portail-usagers/src/_common/mocks/DEFAULT_USAGER.const.ts +++ b/packages/portail-usagers/src/_common/mocks/DEFAULT_USAGER.const.ts @@ -65,4 +65,5 @@ export const DEFAULT_USAGER: PortailUsagerPublic = { export const DEFAULT_USAGER_PROFILE: PortailUsagerProfile = { usager: DEFAULT_USAGER, + acceptTerms: new Date(), }; diff --git a/packages/portail-usagers/src/app/app.component.ts b/packages/portail-usagers/src/app/app.component.ts index fc88583caf..229348c5c4 100644 --- a/packages/portail-usagers/src/app/app.component.ts +++ b/packages/portail-usagers/src/app/app.component.ts @@ -5,6 +5,8 @@ import { NavigationEnd, Router } from "@angular/router"; import { filter } from "rxjs"; import { LIENS_PARTENAIRES } from "./modules/general/components/_static/plan-site/LIENS_PARTENAIRES.const"; import { PortailUsagerProfile } from "@domifa/common"; +import { globalConstants } from "./shared"; +import { MatomoTracker } from "ngx-matomo-client"; @Component({ selector: "app-root", @@ -22,6 +24,7 @@ export class AppComponent implements OnInit { private readonly titleService: Title, private readonly router: Router, private readonly usagerAuthService: UsagerAuthService, + private readonly matomo: MatomoTracker, ) { this.apiVersion = null; this.usagerProfile = null; @@ -35,13 +38,26 @@ export class AppComponent implements OnInit { public matomoInfo: boolean; public initMatomo(): void { - const matomo = localStorage.getItem("matomo"); + const matomo = globalConstants.getItem("matomo"); this.matomoInfo = matomo === "done"; + + if (globalConstants.getItem("matomo-opted-in") === null) { + globalConstants.setItem("matomo-opted-in", JSON.stringify(true)); + } + + const disableMatomo = + JSON.parse(globalConstants.getItem("matomo-opted-in")) === true; + + if (!disableMatomo) { + this.matomo.optUserOut(); + } else { + globalConstants.setItem("matomo-opted-in", JSON.stringify(true)); + } } public closeMatomo(): void { this.matomoInfo = true; - localStorage.setItem("matomo", "done"); + globalConstants.setItem("matomo", "done"); } public ngOnInit(): void { diff --git a/packages/portail-usagers/src/app/app.module.ts b/packages/portail-usagers/src/app/app.module.ts index 49393d6ca7..568c0177a0 100644 --- a/packages/portail-usagers/src/app/app.module.ts +++ b/packages/portail-usagers/src/app/app.module.ts @@ -25,7 +25,7 @@ import { SharedModule } from "./modules/shared/shared.module"; import { CustomToastService } from "./modules/shared/services/custom-toast.service"; import { GeneralModule } from "./modules/general/general.module"; import { MATOMO_INJECTORS } from "./shared"; -import { UserIdleModule } from "angular-user-idle"; +import { provideUserIdleConfig } from "angular-user-idle"; import { registerLocaleData } from "@angular/common"; import localeFr from "@angular/common/locales/fr"; @@ -46,8 +46,7 @@ registerLocaleData(localeFr, "fr"); NgbModule, SharedModule, ReactiveFormsModule, - ...MATOMO_INJECTORS, - UserIdleModule.forRoot({ idle: 3600, timeout: 60, ping: 20 }), + MATOMO_INJECTORS, ], providers: [ UsagerAuthService, @@ -55,6 +54,7 @@ registerLocaleData(localeFr, "fr"); { provide: LOCALE_ID, useValue: "fr" }, { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true }, { provide: ErrorHandler, useClass: SentryErrorHandler }, + provideUserIdleConfig({ idle: 3600, timeout: 60, ping: 20 }), ], schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], }) diff --git a/packages/portail-usagers/src/app/guards/auth-guard.ts b/packages/portail-usagers/src/app/guards/auth-guard.ts index 83f5941040..17d1aea5a5 100644 --- a/packages/portail-usagers/src/app/guards/auth-guard.ts +++ b/packages/portail-usagers/src/app/guards/auth-guard.ts @@ -1,7 +1,6 @@ import { Injectable } from "@angular/core"; import { ActivatedRouteSnapshot, - CanActivate, Router, RouterStateSnapshot, } from "@angular/router"; @@ -11,7 +10,7 @@ import { catchError, map } from "rxjs/operators"; import { UsagerAuthService } from "../modules/usager-auth/services/usager-auth.service"; @Injectable({ providedIn: "root" }) -export class AuthGuard implements CanActivate { +export class AuthGuard { constructor( private readonly router: Router, private readonly authService: UsagerAuthService, diff --git a/packages/portail-usagers/src/app/modules/general/components/_static/cgu/cgu.component.ts b/packages/portail-usagers/src/app/modules/general/components/_static/cgu/cgu.component.ts index 062f40c219..5925b90eca 100644 --- a/packages/portail-usagers/src/app/modules/general/components/_static/cgu/cgu.component.ts +++ b/packages/portail-usagers/src/app/modules/general/components/_static/cgu/cgu.component.ts @@ -1,13 +1,12 @@ -import { Component, OnInit } from "@angular/core"; +import { Component } from "@angular/core"; import { Title } from "@angular/platform-browser"; @Component({ selector: "app-cgu", templateUrl: "./cgu.component.html", }) -export class CguComponent implements OnInit { - constructor(private readonly titleService: Title) {} - public ngOnInit(): void { +export class CguComponent { + constructor(private readonly titleService: Title) { this.titleService.setTitle("Conditions générales d'utilisation"); } } diff --git a/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.html b/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.html index 55ade89f2d..c3eeac5ce3 100644 --- a/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.html +++ b/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.html @@ -238,6 +238,24 @@

Cookies

> +
+

+ +

diff --git a/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.spec.ts b/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.spec.ts index 5d151158b3..ccf7ea3c1a 100644 --- a/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.spec.ts +++ b/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; import { PolitiqueComponent } from "./politique.component"; +import { ReactiveFormsModule, FormsModule } from "@angular/forms"; +import { MATOMO_INJECTORS } from "../../../../../shared"; describe("PolitiqueComponent", () => { let component: PolitiqueComponent; @@ -9,6 +11,7 @@ describe("PolitiqueComponent", () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [PolitiqueComponent], + imports: [ReactiveFormsModule, MATOMO_INJECTORS, FormsModule], }).compileComponents(); })); diff --git a/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.ts b/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.ts index 616156a3dc..9c334c2c41 100644 --- a/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.ts +++ b/packages/portail-usagers/src/app/modules/general/components/_static/politique/politique.component.ts @@ -1,14 +1,32 @@ -import { Component, OnInit } from "@angular/core"; +import { Component } from "@angular/core"; import { Title } from "@angular/platform-browser"; +import { MatomoTracker } from "ngx-matomo-client"; +import { globalConstants } from "../../../../../shared"; @Component({ selector: "app-politique", templateUrl: "./politique.component.html", }) -export class PolitiqueComponent implements OnInit { - public constructor(private readonly titleService: Title) {} +export class PolitiqueComponent { + optedOut$: Promise; - public ngOnInit(): void { + public constructor( + private readonly titleService: Title, + private readonly tracker: MatomoTracker, + ) { + this.optedOut$ = tracker.isUserOptedOut(); this.titleService.setTitle("Politique de confidentialité de Mon DomiFa"); } + + handleChange(optOut: any) { + if (optOut) { + this.tracker.optUserOut(); + globalConstants.setItem("matomo-opted-in", false); + } else { + globalConstants.setItem("matomo-opted-in", true); + this.tracker.forgetUserOptOut(); + } + + this.optedOut$ = this.tracker.isUserOptedOut(); + } } diff --git a/packages/portail-usagers/src/app/modules/general/general.module.ts b/packages/portail-usagers/src/app/modules/general/general.module.ts index f448e76279..a425c66274 100644 --- a/packages/portail-usagers/src/app/modules/general/general.module.ts +++ b/packages/portail-usagers/src/app/modules/general/general.module.ts @@ -19,6 +19,7 @@ import { CguComponent } from "./components/_static/cgu/cgu.component"; import { RgaaComponent } from "./components/_static/rgaa/rgaa.component"; import { IdleManagerComponent } from "./components/idle-manager/idle-manager.component"; import { PlanSiteComponent } from "./components/_static/plan-site/plan-site.component"; +import { FormsModule } from "@angular/forms"; @NgModule({ declarations: [ @@ -44,6 +45,7 @@ import { PlanSiteComponent } from "./components/_static/plan-site/plan-site.comp RouterModule.forChild([]), SharedModule, NgbModule, + FormsModule, ], schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], diff --git a/packages/portail-usagers/src/app/modules/usager-account/components/home-usager/home-usager.component.html b/packages/portail-usagers/src/app/modules/usager-account/components/home-usager/home-usager.component.html index 2e5d636133..681ba0a748 100644 --- a/packages/portail-usagers/src/app/modules/usager-account/components/home-usager/home-usager.component.html +++ b/packages/portail-usagers/src/app/modules/usager-account/components/home-usager/home-usager.component.html @@ -3,7 +3,7 @@

Bonjour {{ usagerProfile.usager.prenom }} {{ usagerProfile.usager.nom }} - - {{ usagerProfile.usager.customRef || usagerProfile.usager.customRef }} ! + {{ usagerProfile.usager.customRef }} !

Bienvenue dans votre espace de suivi de courrier { + if (!apiResponse?.acceptTerms) { + this.router.navigate(["/account/accept-terms"]); + return; + } this.usagerProfile = apiResponse; }, ); diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.css b/packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.css similarity index 100% rename from packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.css rename to packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.css diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.html b/packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.html similarity index 98% rename from packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.html rename to packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.html index 783176040b..7ad1d9864c 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.html +++ b/packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.html @@ -1,7 +1,6 @@ -
+

Veuillez lire et accepter les CGU

-

Les conditions générales d'utilisation de DomiFa évoluent.
Afin de pouvoir continuer à l'utiliser, merci de lire et accepter les nouvelles diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.spec.ts b/packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.spec.ts similarity index 85% rename from packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.spec.ts rename to packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.spec.ts index 0fa54d4aa1..edca3bcc5d 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.spec.ts +++ b/packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from "@angular/core/testing"; import { UsagerAcceptCguComponent } from "./usager-accept-cgu.component"; +import { HttpClientTestingModule } from "@angular/common/http/testing"; describe("UsagerAcceptCguComponent", () => { let component: UsagerAcceptCguComponent; @@ -9,6 +10,7 @@ describe("UsagerAcceptCguComponent", () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [UsagerAcceptCguComponent], + imports: [HttpClientTestingModule], }).compileComponents(); fixture = TestBed.createComponent(UsagerAcceptCguComponent); diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.ts b/packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.ts similarity index 85% rename from packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.ts rename to packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.ts index 75574b1834..21eec5af8a 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-accept-cgu/usager-accept-cgu.component.ts +++ b/packages/portail-usagers/src/app/modules/usager-account/components/usager-accept-cgu/usager-accept-cgu.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from "@angular/core"; +import { Component } from "@angular/core"; import { AbstractControl, FormBuilder, @@ -6,8 +6,8 @@ import { Validators, } from "@angular/forms"; import { Subscription } from "rxjs"; -import { CustomToastService } from "../../shared/services/custom-toast.service"; -import { UsagerAuthService } from "../services/usager-auth.service"; +import { CustomToastService } from "../../../shared/services/custom-toast.service"; +import { UsagerAuthService } from "../../../usager-auth/services/usager-auth.service"; import { PortailUsagerProfile } from "@domifa/common"; import { Router } from "@angular/router"; @@ -16,7 +16,7 @@ import { Router } from "@angular/router"; templateUrl: "./usager-accept-cgu.component.html", styleUrls: ["./usager-accept-cgu.component.css"], }) -export class UsagerAcceptCguComponent implements OnInit { +export class UsagerAcceptCguComponent { public acceptTermsForm!: FormGroup; public loading: boolean; @@ -36,11 +36,11 @@ export class UsagerAcceptCguComponent implements OnInit { this.usagerAuthService.currentUsagerSubject.subscribe( (apiResponse: PortailUsagerProfile | null) => { this.usagerProfile = apiResponse; + if (apiResponse?.acceptTerms) { + this.router.navigate(["/account"]); + } }, ); - } - - ngOnInit(): void { this.initCguForm(); } diff --git a/packages/portail-usagers/src/app/modules/usager-account/usager-account-routing.module.ts b/packages/portail-usagers/src/app/modules/usager-account/usager-account-routing.module.ts index 80c8854849..5b442b9e17 100644 --- a/packages/portail-usagers/src/app/modules/usager-account/usager-account-routing.module.ts +++ b/packages/portail-usagers/src/app/modules/usager-account/usager-account-routing.module.ts @@ -1,8 +1,15 @@ import { NgModule } from "@angular/core"; import { RouterModule, Routes } from "@angular/router"; import { HomeUsagerComponent } from "./components/home-usager/home-usager.component"; +import { UsagerAcceptCguComponent } from "./components/usager-accept-cgu/usager-accept-cgu.component"; -const routes: Routes = [{ path: "", component: HomeUsagerComponent }]; +const routes: Routes = [ + { path: "", component: HomeUsagerComponent }, + { + path: "accept-terms", + component: UsagerAcceptCguComponent, + }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/packages/portail-usagers/src/app/modules/usager-account/usager-account.module.ts b/packages/portail-usagers/src/app/modules/usager-account/usager-account.module.ts index 1e47ad186d..c871df440e 100644 --- a/packages/portail-usagers/src/app/modules/usager-account/usager-account.module.ts +++ b/packages/portail-usagers/src/app/modules/usager-account/usager-account.module.ts @@ -8,6 +8,9 @@ import { SectionCourriersComponent } from "./components/section-courriers/sectio import { SectionInfosComponent } from "./components/section-infos/section-infos.component"; import { SectionOptionsComponent } from "./components/section-options/section-options.component"; import { SharedModule } from "../shared/shared.module"; +import { UsagerAcceptCguComponent } from "./components/usager-accept-cgu/usager-accept-cgu.component"; +import { GeneralModule } from "../general/general.module"; +import { FormsModule, ReactiveFormsModule } from "@angular/forms"; @NgModule({ declarations: [ @@ -15,11 +18,15 @@ import { SharedModule } from "../shared/shared.module"; SectionInfosComponent, SectionCourriersComponent, SectionOptionsComponent, + UsagerAcceptCguComponent, ], imports: [ CommonModule, UsagerAccountRoutingModule, SharedModule, + GeneralModule, + FormsModule, + ReactiveFormsModule, FontAwesomeModule, ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/portail-usagers/src/app/modules/usager-auth/services/usager-auth.service.ts b/packages/portail-usagers/src/app/modules/usager-auth/services/usager-auth.service.ts index 8357d38fa4..2e035c56b2 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/services/usager-auth.service.ts +++ b/packages/portail-usagers/src/app/modules/usager-auth/services/usager-auth.service.ts @@ -17,7 +17,7 @@ const END_POINT_AUTH = environment.apiUrl + "portail-usagers/auth"; const END_POINT_PROFILE = environment.apiUrl + "portail-usagers/profile"; const TOKEN_KEY = "usager-auth-token"; -const USER_KEY = "usager-auth-datas"; +const USER_KEY = "usager-auth-data"; @Injectable({ providedIn: "root", diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-auth-routing.module.ts b/packages/portail-usagers/src/app/modules/usager-auth/usager-auth-routing.module.ts index 0ddeb17c92..788d6fcb3e 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-auth-routing.module.ts +++ b/packages/portail-usagers/src/app/modules/usager-auth/usager-auth-routing.module.ts @@ -1,12 +1,8 @@ import { NgModule } from "@angular/core"; import { RouterModule, Routes } from "@angular/router"; import { UsagerLoginComponent } from "./usager-login/usager-login.component"; -import { UsagerAcceptCguComponent } from "./usager-accept-cgu/usager-accept-cgu.component"; -const routes: Routes = [ - { path: "login", component: UsagerLoginComponent }, - { path: "accept-terms", component: UsagerAcceptCguComponent }, -]; +const routes: Routes = [{ path: "login", component: UsagerLoginComponent }]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-auth.module.ts b/packages/portail-usagers/src/app/modules/usager-auth/usager-auth.module.ts index 0a2d9689b5..afca637a46 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-auth.module.ts +++ b/packages/portail-usagers/src/app/modules/usager-auth/usager-auth.module.ts @@ -9,11 +9,9 @@ import { UsagerAuthService } from "./services/usager-auth.service"; import { UsagerAuthRoutingModule } from "./usager-auth-routing.module"; import { UsagerLoginComponent } from "./usager-login/usager-login.component"; -import { UsagerAcceptCguComponent } from "./usager-accept-cgu/usager-accept-cgu.component"; -import { GeneralModule } from "../general/general.module"; @NgModule({ - declarations: [UsagerLoginComponent, UsagerAcceptCguComponent], + declarations: [UsagerLoginComponent], imports: [ CommonModule, UsagerAuthRoutingModule, @@ -22,7 +20,6 @@ import { GeneralModule } from "../general/general.module"; FontAwesomeModule, SharedModule, ReactiveFormsModule, - GeneralModule, ], providers: [UsagerAuthService], }) diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.html b/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.html index 85f5ecf801..f863296d33 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.html +++ b/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.html @@ -269,7 +269,7 @@

Connexion à Mon DomiFa

name="acceptTerms" class="form-check-input me-2" [ngClass]="{ - 'is-invalid': f.acceptTerms?.errors + 'is-invalid': f.acceptTerms.errors }" [attr.aria-describedby]=" f.acceptTerms.errors ? 'invalid-cgu-choice' : null diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.spec.ts b/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.spec.ts index addd2998da..245076ed14 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.spec.ts +++ b/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.spec.ts @@ -18,7 +18,7 @@ describe("UsagerLoginComponent", () => { imports: [ HttpClientTestingModule, ReactiveFormsModule, - ...MATOMO_INJECTORS, + MATOMO_INJECTORS, NgbModule, FormsModule, RouterTestingModule, diff --git a/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.ts b/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.ts index a0776a911d..4e4c284121 100644 --- a/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.ts +++ b/packages/portail-usagers/src/app/modules/usager-auth/usager-login/usager-login.component.ts @@ -98,7 +98,7 @@ export class UsagerLoginComponent implements OnInit, OnDestroy { { value: "", disabled: true }, Validators.compose([Validators.required, Validators.minLength(8)]), ], - acceptTerms: [{ value: "", disabled: true }, [Validators.required]], + acceptTerms: [{ value: false, disabled: true }, [Validators.required]], }, { validators: [ @@ -153,13 +153,7 @@ export class UsagerLoginComponent implements OnInit, OnDestroy { this.toastr.success("Connexion réussie !"); this.authService.saveToken(apiAuthResponse); - if (!apiAuthResponse.acceptTerms) { - this.router.navigate(["/auth/accept-terms"]); - return; - } - this.loading = false; - this.router.navigate(["/account"]); this.matomo.trackEvent( "login-portail-usagers", @@ -167,6 +161,12 @@ export class UsagerLoginComponent implements OnInit, OnDestroy { "null", 1, ); + if (!apiAuthResponse.acceptTerms) { + this.router.navigate(["/account/accept-terms"]); + return; + } + + this.router.navigate(["/account"]); }, error: (err) => { diff --git a/packages/portail-usagers/src/app/shared/global-constants.class.ts b/packages/portail-usagers/src/app/shared/global-constants.class.ts index 492c739b49..50fd55bb77 100644 --- a/packages/portail-usagers/src/app/shared/global-constants.class.ts +++ b/packages/portail-usagers/src/app/shared/global-constants.class.ts @@ -8,21 +8,12 @@ export class GlobalConstants { if (typeof localStorage !== "undefined" && localStorage !== null) { this.storageName = "localStorage"; this.storage = localStorage; - if (!localStorage.getItem("DATA_CLEAN")) { - localStorage.clear(); - localStorage.setItem("DATA_CLEAN", "true"); - } } else if ( typeof sessionStorage !== "undefined" && sessionStorage !== null ) { this.storageName = "sessionStorage"; this.storage = sessionStorage; - - if (!sessionStorage.getItem("DATA_CLEAN")) { - sessionStorage.clear(); - sessionStorage.setItem("DATA_CLEAN", "true"); - } } else { this.storageName = "globalVariable"; this.storage = null;