From edef309e1740f6e106b651bfcd698402351dee27 Mon Sep 17 00:00:00 2001 From: Arthur Danjou Date: Thu, 10 Jun 2021 19:08:34 +0200 Subject: [PATCH] Working with auth --- app/Controllers/Http/LinksController.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Http/LinksController.ts b/app/Controllers/Http/LinksController.ts index 15c33a0..7c6fdf9 100644 --- a/app/Controllers/Http/LinksController.ts +++ b/app/Controllers/Http/LinksController.ts @@ -47,14 +47,16 @@ export default class LinksController { } } - public async updateLink ({request}: HttpContextContract) { + public async updateLink ({request, auth}: HttpContextContract) { + await auth.authenticate() const link = await Link.findByOrFail('code', request.input('link')) const data = await request.validate(UpdateValidator) await link.merge(data).save() return link } - public async deleteLink ({request}: HttpContextContract) { + public async deleteLink ({request, auth}: HttpContextContract) { + await auth.authenticate() const code = request.input('code') const link = await Link.findByOrFail('code', code) await link.delete()