feat(auth): add profile and QR card identification endpoints
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { AppError } from '../errors/app-error';
|
||||
import { getProfil, identifierParCarte } from '../services/utilisateur.service';
|
||||
|
||||
export async function getMe(req: Request, res: Response): Promise<void> {
|
||||
const user = req.user;
|
||||
if (!user) {
|
||||
throw new AppError(401, 'Authentification requise');
|
||||
}
|
||||
|
||||
const profil = await getProfil(user.id);
|
||||
res.json({ data: profil });
|
||||
}
|
||||
|
||||
export async function identifier(req: Request, res: Response): Promise<void> {
|
||||
const qr = req.params.qr;
|
||||
if (typeof qr !== 'string') {
|
||||
throw new AppError(400, 'QR code invalide');
|
||||
}
|
||||
|
||||
const profil = await identifierParCarte(qr);
|
||||
res.json({ data: profil });
|
||||
}
|
||||
Reference in New Issue
Block a user