From 98f9f3a012001daa05885300a75a8de3b67fdcd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Santanch=C3=A8?= Date: Tue, 1 Feb 2022 07:12:55 -0300 Subject: [PATCH] feat (term): retrieve current user --- src/adonisjs/app/Controllers/Http/v1/TermController.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/adonisjs/app/Controllers/Http/v1/TermController.js b/src/adonisjs/app/Controllers/Http/v1/TermController.js index 4e9e14b..a6ecc96 100644 --- a/src/adonisjs/app/Controllers/Http/v1/TermController.js +++ b/src/adonisjs/app/Controllers/Http/v1/TermController.js @@ -78,12 +78,15 @@ class TermController { * @param {Response} ctx.response * @param {View} ctx.view */ - async showTermUser ({ params, request, response, view }) { + async showTermUser ({ params, request, response, view, auth }) { try { + let userId = request.input('userId') + if (userId == null) + userId = auth.user.id const uterm = await Database .select('*') .from('users_terms') - .where('user_id', request.input('userId')) + .where('user_id', userId) .where('term_id', request.input('termId')) if (uterm != null) return response.json(uterm)