Changed register api route and added user deletion route

This commit is contained in:
Nicolai Ort 2021-08-18 17:46:49 +02:00
parent d889432ce8
commit 588f3bae89
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 9 additions and 1 deletions

View File

@ -223,7 +223,7 @@ fastify.get('/api/:shortcode', async (req, res) => {
//User registration
fastify.post('/api/register', async (req, res) => {
fastify.post('/api/auth/register', async (req, res) => {
if (!config.registrationEnabled) {
res.statusCode = 400;
return "Registration was disabled by your admin";
@ -347,6 +347,14 @@ fastify.after(() => {
return "Done!";
});
fastify.post('/api/auth/deleteme', { onRequest: fastify.auth([fastify.basicAuth, fastify.verifyJWT]) }, async (req, reply) => {
await knex('users')
.where('username', '=', req.user)
.delete();
return "Done!";
});
});