diff --git a/packages/backend/src/auth/guards/structure-information-access.guard.ts b/packages/backend/src/auth/guards/structure-information-access.guard.ts index b7f5f11855..f6212ec3e3 100644 --- a/packages/backend/src/auth/guards/structure-information-access.guard.ts +++ b/packages/backend/src/auth/guards/structure-information-access.guard.ts @@ -19,7 +19,7 @@ export class StructureInformationAccessGuard implements CanActivate { typeof r.user.structureId === "undefined" ) { appLogger.error( - `[StructureInformationAccessGuard] invalid uuid or structureId`, + "[StructureInformationAccessGuard] invalid uuid or structureId", { sentry: true, context: { @@ -49,7 +49,7 @@ export class StructureInformationAccessGuard implements CanActivate { r.structureInformation = structureInformation; return r; } catch (e) { - appLogger.error(`[UsagerAccessGuard] structureInformation not found`, { + appLogger.error("[UsagerAccessGuard] structureInformation not found", { sentry: true, context: { uuid, diff --git a/packages/backend/src/auth/services/auth-checker.service.ts b/packages/backend/src/auth/services/auth-checker.service.ts index 8dce75268e..c698cdf1fa 100644 --- a/packages/backend/src/auth/services/auth-checker.service.ts +++ b/packages/backend/src/auth/services/auth-checker.service.ts @@ -20,7 +20,7 @@ function checkRole( const isValidRole = user && expectedRoles.includes(user.role); if (user && !isValidRole) { - appLogger.error(`[authChecker] invalid role`, { + appLogger.error("[authChecker] invalid role", { sentry: true, context: { role: user.role, user: user.id, expectedRoles }, }); @@ -37,7 +37,7 @@ function checkProfile( const isValidRole = user && expectedProfiles.includes(userProfile); if (user && !isValidRole) { - appLogger.error(`[authChecker] invalid profile`, { + appLogger.error("[authChecker] invalid profile", { context: { userProfile, user: user._userId, expectedProfiles }, }); } diff --git a/packages/backend/src/modules/mails/services/templates-renderers/user-reset-password/userResetPasswordEmailSender.service.ts b/packages/backend/src/modules/mails/services/templates-renderers/user-reset-password/userResetPasswordEmailSender.service.ts index fd7dfa5d26..168521f0f3 100644 --- a/packages/backend/src/modules/mails/services/templates-renderers/user-reset-password/userResetPasswordEmailSender.service.ts +++ b/packages/backend/src/modules/mails/services/templates-renderers/user-reset-password/userResetPasswordEmailSender.service.ts @@ -54,7 +54,7 @@ async function sendMail({ meta: { "lien de ré-initialisation": lien }, }; - messageEmailSender.sendMessageLater(messageContent, { + await messageEmailSender.sendMessageLater(messageContent, { messageEmailId, }); } diff --git a/packages/backend/src/modules/portail-admin/controllers/admin-structures/admin-structures.controller.ts b/packages/backend/src/modules/portail-admin/controllers/admin-structures/admin-structures.controller.ts index f6cbd9b255..c5f234e1b9 100644 --- a/packages/backend/src/modules/portail-admin/controllers/admin-structures/admin-structures.controller.ts +++ b/packages/backend/src/modules/portail-admin/controllers/admin-structures/admin-structures.controller.ts @@ -6,6 +6,7 @@ import { HttpStatus, Res, UseGuards, + Param, } from "@nestjs/common"; import { AuthGuard } from "@nestjs/passport"; import { ApiBearerAuth, ApiTags } from "@nestjs/swagger"; @@ -23,6 +24,8 @@ import { ExpressResponse } from "../../../../util/express"; import { UserAdminAuthenticated, UserStructureAuthenticated, + UserStructureSecurityEvent, + UserStructureTokens, } from "../../../../_common/model"; import { AdminStructuresService } from "../../services"; import { CurrentUser } from "../../../../auth/decorators/current-user.decorator"; @@ -30,7 +33,12 @@ import { UsersController } from "../../../../users/controllers/users.controller" import { RegisterUserAdminDto } from "../../../../users/dto"; import { format } from "date-fns"; import { structureCreatorService } from "../../../../structures/services"; -import { DEPARTEMENTS_MAP, REGIONS_LISTE, Structure } from "@domifa/common"; +import { + DEPARTEMENTS_MAP, + REGIONS_LISTE, + Structure, + UserStructure, +} from "@domifa/common"; import { MetabaseStatsDto } from "../../_dto/MetabaseStats.dto"; import { domifaConfig } from "../../../../config"; import { sign } from "jsonwebtoken"; @@ -40,6 +48,10 @@ import { StructureConfirmationDto } from "../../_dto"; import { StructureAdminForList } from "../../types"; import { userAccountActivatedEmailSender } from "../../../mails/services/templates-renderers"; +export type UserStructureWithSecurity = UserStructure & { + temporaryTokens: UserStructureTokens; + events: UserStructureSecurityEvent; +}; @UseGuards(AuthGuard("jwt"), AppUserGuard) @Controller("admin/structures") @ApiTags("dashboard") @@ -98,6 +110,42 @@ export class AdminStructuresController { return await this.adminStructuresService.getAdminStructuresListData(); } + @Get("structure/:structureId") + @AllowUserProfiles("super-admin-domifa") + public async getStructure( + @CurrentUser() _user: UserAdminAuthenticated, + @Param("structureId") structureId: number + ): Promise { + return await structureRepository.findOneOrFail({ + where: { id: structureId }, + }); + } + + @Get("structure/:structureId/users") + @AllowUserProfiles("super-admin-domifa") + public async getUsers( + @CurrentUser() _user: UserAdminAuthenticated, + @Param("structureId") structureId: number + ): Promise> { + return (await userStructureRepository + .createQueryBuilder("u") + .leftJoinAndSelect("user_structure_security", "uss", "u.id = uss.user_id") + .select([ + "u.nom", + "u.prenom", + "u.mail", + "u.role", + "u.lastLogin", + "u.id", + "u.uuid", + "u.createdAt", + "uss.temporaryTokens", + "uss.eventsHistory", + ]) + .where({ structureId }) + .getMany()) as unknown as UserStructureWithSecurity[]; + } + @AllowUserProfiles("super-admin-domifa") @Post("confirm-structure-creation") public async confirmStructureCreation( diff --git a/packages/backend/src/structures/services/location.service.ts b/packages/backend/src/structures/services/location.service.ts index db3d2d8ba7..821f0038ba 100644 --- a/packages/backend/src/structures/services/location.service.ts +++ b/packages/backend/src/structures/services/location.service.ts @@ -66,6 +66,7 @@ export const getLocation = async (address: string): Promise => { apiUrl, { params, + timeout: 4000, } ); diff --git a/packages/backend/src/users/controllers/users.public.controller.ts b/packages/backend/src/users/controllers/users.public.controller.ts index 5a999bee56..ec3576bf1a 100644 --- a/packages/backend/src/users/controllers/users.public.controller.ts +++ b/packages/backend/src/users/controllers/users.public.controller.ts @@ -15,7 +15,7 @@ import { userStructureSecurityResetPasswordUpdater, userStructureSecurityResetPasswordInitiator, } from "../../database"; -import { ExpressResponse } from "../../util"; +import { appLogger, ExpressResponse } from "../../util"; import { EmailDto, ResetPasswordDto } from "../dto"; import { userResetPasswordEmailSender } from "../../modules/mails/services/templates-renderers"; @@ -94,7 +94,9 @@ export class UsersPublicController { user, token: userSecurity.temporaryTokens.token, }); - } catch (err) {} + } catch (err) { + appLogger.error("Cannot reset password"); + } return res.status(HttpStatus.OK).json({ message: "OK" }); } } diff --git a/packages/frontend/src/app/modules/import-usagers/components/import/import.component.html b/packages/frontend/src/app/modules/import-usagers/components/import/import.component.html index 6ca7ff9468..33644898d7 100644 --- a/packages/frontend/src/app/modules/import-usagers/components/import/import.component.html +++ b/packages/frontend/src/app/modules/import-usagers/components/import/import.component.html @@ -94,7 +94,11 @@

Votre fichier est prêt à être importé !

-
+
Télécharger le Cerfa d'attestation de demande @@ -48,7 +53,12 @@ *ngIf="usager.decision.statut === 'VALIDE'" ngbDropdownItem type="button" - (click)="getDomifaCustomDoc(usager.ref, 'attestation_postale')" + (click)=" + getDomifaCustomDoc( + usager.ref, + StructureDocTypesAvailable.attestation_postale + ) + " > Télécharger l'attestation postale diff --git a/packages/frontend/src/app/modules/manage-usagers/components/manage-download-docs/manage-download-docs.component.ts b/packages/frontend/src/app/modules/manage-usagers/components/manage-download-docs/manage-download-docs.component.ts index f52026b5cf..29408221d2 100644 --- a/packages/frontend/src/app/modules/manage-usagers/components/manage-download-docs/manage-download-docs.component.ts +++ b/packages/frontend/src/app/modules/manage-usagers/components/manage-download-docs/manage-download-docs.component.ts @@ -28,6 +28,8 @@ export class ManageDownloadDocsComponent implements OnDestroy { public me!: UserStructure | null; @Input() public usager!: UsagerFormModel; + public readonly CerfaDocType = CerfaDocType; + public readonly StructureDocTypesAvailable = StructureDocTypesAvailable; constructor( private readonly documentService: DocumentService, diff --git a/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html b/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html index bb7e4403a6..76de2871e3 100644 --- a/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html +++ b/packages/frontend/src/app/modules/usager-dossier/components/step-rdv/step-rdv.component.html @@ -50,7 +50,7 @@


- diff --git a/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.html b/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.html deleted file mode 100644 index f1c2269ba8..0000000000 --- a/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.html +++ /dev/null @@ -1 +0,0 @@ -

admin-users-table works!

diff --git a/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.spec.ts b/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.spec.ts deleted file mode 100644 index 26c6e8dd07..0000000000 --- a/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ComponentFixture, TestBed } from "@angular/core/testing"; - -import { AdminUsersTableComponent } from "./admin-users-table.component"; - -describe("AdminUsersTableComponent", () => { - let component: AdminUsersTableComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AdminUsersTableComponent], - }).compileComponents(); - - fixture = TestBed.createComponent(AdminUsersTableComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it("should create", () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.ts b/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.ts deleted file mode 100644 index cf47410567..0000000000 --- a/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from "@angular/core"; - -@Component({ - selector: "app-admin-users-table", - standalone: true, - imports: [], - templateUrl: "./admin-users-table.component.html", - styleUrl: "./admin-users-table.component.css", -}) -export class AdminUsersTableComponent {} diff --git a/packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.css b/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.css similarity index 100% rename from packages/portail-admins/src/app/modules/admin-structures/components/admin-users-table/admin-users-table.component.css rename to packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.css diff --git a/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.html b/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.html new file mode 100644 index 0000000000..7a9d7ec825 --- /dev/null +++ b/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.html @@ -0,0 +1,28 @@ +
+
+
+
+

+ {{ structure.nom }} +

+
+
+ + +
+
+
+
+
+
+
diff --git a/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.spec.ts b/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.spec.ts new file mode 100644 index 0000000000..58885ba8c0 --- /dev/null +++ b/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from "@angular/core/testing"; + +import { StructureComponent } from "./structure.component"; + +describe("StructureComponent", () => { + let component: StructureComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [StructureComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(StructureComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.ts b/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.ts new file mode 100644 index 0000000000..0d48935588 --- /dev/null +++ b/packages/portail-admins/src/app/modules/admin-structures/components/structure/structure.component.ts @@ -0,0 +1,45 @@ +import { Component, OnInit } from "@angular/core"; +import { AdminStructuresApiClient } from "../../../shared/services"; +import { Title } from "@angular/platform-browser"; +import { Structure } from "@domifa/common"; +import { Subscription } from "rxjs"; +import { ActivatedRoute, Router } from "@angular/router"; +import { isUUID } from "class-validator"; + +@Component({ + selector: "app-structure", + + templateUrl: "./structure.component.html", + styleUrl: "./structure.component.css", +}) +export class StructureComponent implements OnInit { + private subscription = new Subscription(); + public searching = true; + public structure: Structure; + public structureUuid: string; + constructor( + private readonly adminStructuresApiClient: AdminStructuresApiClient, + private readonly titleService: Title, + private readonly route: ActivatedRoute, + private readonly router: Router + ) { + this.titleService.setTitle("Administration de la structure"); + + if (isUUID(this.route.snapshot.params.structureUuid)) { + this.structureUuid = this.route.snapshot.params.structureUuid; + } else { + this.router.navigate(["404"]); + } + } + + ngOnInit(): void { + this.subscription.add( + this.adminStructuresApiClient + .getStructure(this.structureUuid) + .subscribe((structure) => { + this.structure = structure; + this.searching = false; + }) + ); + } +} diff --git a/packages/portail-admins/src/app/modules/shared/services/api/admin-structures-api-client.service.ts b/packages/portail-admins/src/app/modules/shared/services/api/admin-structures-api-client.service.ts index cc2d546330..410fc23063 100644 --- a/packages/portail-admins/src/app/modules/shared/services/api/admin-structures-api-client.service.ts +++ b/packages/portail-admins/src/app/modules/shared/services/api/admin-structures-api-client.service.ts @@ -21,6 +21,11 @@ export class AdminStructuresApiClient { this.http = http; } + public getStructure(structureUuid: string): Observable { + return this.http.get( + `${environment.apiUrl}admin/structures/${structureUuid}` + ); + } public deleteSendInitialMail(structureUuid: string) { return this.http.put( `${environment.apiUrl}admin/structures-delete/send-mail/${structureUuid}`,