feat(#111): Reprise après refus – backend
- GET /auth/reprise-dossier?token= : dossier pour préremplir (token seul) - PATCH /auth/reprise-resoumettre : token + champs modifiables → en_attente, token invalidé - POST /auth/reprise-identify : numero_dossier + email → type + token - UserService: findByTokenReprise, resoumettreReprise, findByNumeroDossierAndEmailForReprise Made-with: Cursor
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
ConflictException,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
UnauthorizedException,
|
||||
BadRequestException,
|
||||
} from '@nestjs/common';
|
||||
@@ -22,6 +23,8 @@ import { Children, StatutEnfantType } from 'src/entities/children.entity';
|
||||
import { ParentsChildren } from 'src/entities/parents_children.entity';
|
||||
import { AssistanteMaternelle } from 'src/entities/assistantes_maternelles.entity';
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
import { RepriseDossierDto } from './dto/reprise-dossier.dto';
|
||||
import { RepriseIdentifyResponseDto } from './dto/reprise-identify.dto';
|
||||
import { AppConfigService } from 'src/modules/config/config.service';
|
||||
import { validateNir } from 'src/common/utils/nir.util';
|
||||
import { NumeroDossierService } from 'src/modules/numero-dossier/numero-dossier.service';
|
||||
@@ -501,4 +504,47 @@ export class AuthService {
|
||||
async logout(userId: string) {
|
||||
return { success: true, message: 'Deconnexion'}
|
||||
}
|
||||
|
||||
/** GET dossier reprise – token seul. Ticket #111 */
|
||||
async getRepriseDossier(token: string): Promise<RepriseDossierDto> {
|
||||
const user = await this.usersService.findByTokenReprise(token);
|
||||
if (!user) {
|
||||
throw new NotFoundException('Token reprise invalide ou expiré.');
|
||||
}
|
||||
return {
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
prenom: user.prenom,
|
||||
nom: user.nom,
|
||||
telephone: user.telephone,
|
||||
adresse: user.adresse,
|
||||
ville: user.ville,
|
||||
code_postal: user.code_postal,
|
||||
numero_dossier: user.numero_dossier,
|
||||
role: user.role,
|
||||
photo_url: user.photo_url,
|
||||
genre: user.genre,
|
||||
situation_familiale: user.situation_familiale,
|
||||
};
|
||||
}
|
||||
|
||||
/** PUT resoumission reprise. Ticket #111 */
|
||||
async resoumettreReprise(
|
||||
token: string,
|
||||
dto: { prenom?: string; nom?: string; telephone?: string; adresse?: string; ville?: string; code_postal?: string; photo_url?: string },
|
||||
): Promise<Users> {
|
||||
return this.usersService.resoumettreReprise(token, dto);
|
||||
}
|
||||
|
||||
/** POST reprise-identify : numero_dossier + email → type + token. Ticket #111 */
|
||||
async identifyReprise(numero_dossier: string, email: string): Promise<RepriseIdentifyResponseDto> {
|
||||
const user = await this.usersService.findByNumeroDossierAndEmailForReprise(numero_dossier, email);
|
||||
if (!user || !user.token_reprise) {
|
||||
throw new NotFoundException('Aucun dossier en reprise trouvé pour ce numéro et cet email.');
|
||||
}
|
||||
return {
|
||||
type: user.role === RoleType.PARENT ? 'parent' : 'assistante_maternelle',
|
||||
token: user.token_reprise,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user