Skip to content

Commit a18c27b

Browse files
committed
fix(backend): fix statut when you delete an usager
1 parent 6fa8b47 commit a18c27b

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

packages/backend/src/_portail-admin/admin-structures/services/admin-structures.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ export class AdminStructuresService {
190190
> {
191191
return usagerRepository.customCountBy({
192192
countBy: "structureId",
193-
where: typeOrmSearch<UsagerTable>(`decision->>'statut' = 'VALIDE'`),
193+
where: {
194+
statut: "VALIDE",
195+
},
194196
order: {
195197
count: "DESC",
196198
countBy: "ASC",
@@ -236,7 +238,7 @@ export class AdminStructuresService {
236238
}[]
237239
> {
238240
return usagerRepository.countBy({
239-
countBy: `decision->>'statut'` as any,
241+
countBy: "statut",
240242
countByAlias: "statut",
241243
order: { count: "DESC", countBy: "ASC" },
242244
escapeAttributes: false,

packages/backend/src/auth/auth.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { StructuresAuthController } from "./structures-auth.controller";
2626
JwtModule.register({
2727
secret: domifaConfig().security.jwtSecret,
2828
signOptions: {
29-
expiresIn: 36000,
29+
expiresIn: "12h",
3030
},
3131
})
3232
),

packages/backend/src/auth/guards/AppUserGuard.guard.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CanActivate, ExecutionContext, Injectable } from "@nestjs/common";
22
import { Reflector } from "@nestjs/core";
3-
import { addLogContext } from "../../util";
3+
import { addLogContext, appLogger } from "../../util";
44
import { UserProfile, UserStructureAuthenticated } from "../../_common/model";
55
import { authChecker } from "../services";
66
import { expiredTokenRepositiory } from "../../database";
@@ -68,6 +68,12 @@ export class AppUserGuard implements CanActivate {
6868
token: request.headers.authorization,
6969
});
7070

71+
if (isBlacklisted) {
72+
appLogger.error(`[authChecker] expired token`, {
73+
context: { userProfile: user, user: user?._userId },
74+
});
75+
}
76+
7177
// check structure user roles
7278
return (
7379
!isBlacklisted &&

packages/backend/src/usagers/controllers/usagers-decision.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export class UsagersDecisionController {
171171
historique: usager.historique,
172172
etapeDemande: usager.etapeDemande,
173173
decision: usager.decision,
174+
statut: usager.decision.statut,
174175
}
175176
);
176177

packages/backend/src/usagers/controllers/usagers.controller.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,12 @@ export class UsagersController {
162162
.createQueryBuilder()
163163
.select(joinSelectFields(USAGER_LIGHT_ATTRIBUTES))
164164
.where(
165-
`"structureId" = :structureId and statut = :statut AND nom_prenom_ref ILIKE :search`,
165+
`"structureId" = :structureId and statut = 'RADIE' AND nom_prenom_ref ILIKE :search`,
166166
{
167-
statut: "RADIE",
168167
structureId: user.structureId,
169168
search: `%${search}%`,
170169
}
171170
)
172-
.limit(20)
173-
.orderBy({ "decision->>'dateFin'": "DESC" })
174171
.getRawMany();
175172
}
176173

packages/backend/src/usagers/services/usagers.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class UsagersService {
109109
typeDom,
110110
motif: null,
111111
};
112-
usager.statut = usager.decision.statut;
112+
usager.statut = "INSTRUCTION";
113113
// Ajout du précédent état dans l'historique
114114
usagerVisibleHistoryManager.addDecisionToVisibleHistory({ usager });
115115

0 commit comments

Comments
 (0)