feat(idnot): statuts précis auth — 401 email manquant, 403 non-rattachement office
Some checks failed
build-and-push-ext / build_push (push) Failing after 4s

This commit is contained in:
dev4 2025-09-17 15:48:08 +00:00
parent 7541bce346
commit d1075d3f3b

View File

@ -4,7 +4,7 @@ import { IdNotService } from '../services/idnot';
import { authTokens } from '../utils/auth-tokens';
import { IdNotUser, AuthToken } from '../types';
import { Logger } from '../utils/logger';
import { NotFoundError, ExternalServiceError, BusinessRuleError } from '../types/errors';
import { NotFoundError, ExternalServiceError, BusinessRuleError, UnauthorizedError, ForbiddenError } from '../types/errors';
/**
* Pure controller methods that handle business logic
@ -105,7 +105,7 @@ export class IdNotController {
const userData = await IdNotService.getUserData(payload.profile_idn);
if (!userData || !userData.statutDuRattachement || userData.entite.typeEntite.name !== 'office') {
throw new BusinessRuleError('User not attached to an office');
throw new ForbiddenError('User not attached to an office');
}
// Get office location data
@ -143,7 +143,7 @@ export class IdNotController {
};
if (!idNotUser.contact.email) {
throw new BusinessRuleError('User professional email is empty');
throw new UnauthorizedError('Email not found');
}
// Generate auth token