fix(backend): 409 Conflict bij het oproepen van /hello met een reeds geregistreerd account.

This commit is contained in:
Gerald Schmittinger 2025-04-29 23:06:58 +02:00
parent 04fd54e3d6
commit 0b9f765366
2 changed files with 6 additions and 34 deletions

View file

@ -2,10 +2,9 @@ import { UnauthorizedException } from '../exceptions/unauthorized-exception.js';
import { getLogger } from '../logging/initalize.js';
import { AuthenticatedRequest } from '../middleware/auth/authenticated-request.js';
import { envVars, getEnvVar } from '../util/envVars.js';
import { createOrUpdateStudent, createStudent } from '../services/students.js';
import { AuthenticationInfo } from '../middleware/auth/authentication-info.js';
import { createOrUpdateStudent } from '../services/students.js';
import { Request, Response } from 'express';
import { createOrUpdateTeacher, createTeacher } from '../services/teachers.js';
import { createOrUpdateTeacher } from '../services/teachers.js';
interface FrontendIdpConfig {
authority: string;
@ -45,31 +44,6 @@ export function handleGetFrontendAuthConfig(_req: Request, res: Response): void
res.json(getFrontendAuthConfig());
}
export async function handleHello(req: AuthenticatedRequest): Promise<void> {
const auth: AuthenticationInfo = req.auth!;
if (auth.accountType === 'teacher') {
await createTeacher(
{
id: auth.username,
username: auth.username,
firstName: auth.firstName ?? '',
lastName: auth.lastName ?? '',
},
true
);
} else {
await createStudent(
{
id: auth.username,
username: auth.username,
firstName: auth.firstName ?? '',
lastName: auth.lastName ?? '',
},
true
);
}
}
export async function postHelloHandler(req: AuthenticatedRequest, res: Response): Promise<void> {
const auth = req.auth;
if (!auth) {