diff --git a/public/index.html b/public/index.html index d7bc511..23034da 100644 --- a/public/index.html +++ b/public/index.html @@ -48,7 +48,6 @@ const username = document.getElementById('emailInput').value; const password = document.getElementById('passwordInput').value; const errorDisplay = document.getElementById('error'); - const data = await response.json().catch(() => ({ message: "Server antwortet nicht lesbar" })); // Entscheide, an welche Tür (URL) wir klopfen const endpoint = isRegisterMode ? '/auth/register' : '/auth/login'; diff --git a/src/routes/authRoutes.js b/src/routes/authRoutes.js index d1c7773..670e2e3 100644 --- a/src/routes/authRoutes.js +++ b/src/routes/authRoutes.js @@ -38,13 +38,10 @@ router.post('/register', async (req, res) => { const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET, { expiresIn: '24h' }) res.json({ token }) } catch (err) { - console.log(err.message); - // Wenn Prisma meldet, dass der Username schon existiert (Fehlercode P2002) - if (err.code === 'P2002') { - return res.status(409).json({ message: "Username bereits vergeben" }); + console.log(err.message) + res.sendStatus(503) } - res.status(500).json({ message: "Fehler bei der Registrierung" }); -}}) +}) router.post('/login', async (req, res) => { // we get their email, and we look up the password associated with that email in the database