From 4cd0772dd7bf4dbad93d2fc03c8005785f601c3a Mon Sep 17 00:00:00 2001 From: xfarrow Date: Mon, 4 Mar 2024 12:26:06 +0100 Subject: [PATCH] updated activationlink method. Now it is GET --- backend/apis/nodejs/src/app.js | 2 +- backend/apis/nodejs/src/models/activation_model.js | 7 ++++--- backend/apis/nodejs/src/routes/person_routes.js | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/apis/nodejs/src/app.js b/backend/apis/nodejs/src/app.js index 19f50f0..5557c24 100644 --- a/backend/apis/nodejs/src/app.js +++ b/backend/apis/nodejs/src/app.js @@ -56,7 +56,7 @@ publicRoutes.post('/register', personRoutes.registerPerson); publicRoutes.post('/login', personRoutes.login); publicRoutes.get('/person/:id/details', personRoutes.getPerson); publicRoutes.get('/organization/:id', organizationRoutes.getOrganization); -publicRoutes.post('/person/activation', personRoutes.enablePersonByActivationLink); +publicRoutes.get('/person/activation', personRoutes.enablePersonByActivationLink); const protectedRoutes = express.Router(); protectedRoutes.use(jwtUtils.verifyToken); diff --git a/backend/apis/nodejs/src/models/activation_model.js b/backend/apis/nodejs/src/models/activation_model.js index a0afb5a..d6ac8ba 100644 --- a/backend/apis/nodejs/src/models/activation_model.js +++ b/backend/apis/nodejs/src/models/activation_model.js @@ -16,12 +16,13 @@ const knex = require('../utils/knex_config'); /** * Get a Person's ID by its activation identifier * @param {*} identifier - * @returns + * @returns The Person's ID associated with the identifier if present, + * null otherwise */ async function getPersonIdByIdentifier (identifier){ const tuple = await knex('ActivationLink') - .where('identifier', identifier) - .first(); + .where('identifier', identifier) + .first(); if(tuple){ return tuple.person_id; } diff --git a/backend/apis/nodejs/src/routes/person_routes.js b/backend/apis/nodejs/src/routes/person_routes.js index f9688fd..ef39393 100644 --- a/backend/apis/nodejs/src/routes/person_routes.js +++ b/backend/apis/nodejs/src/routes/person_routes.js @@ -228,13 +228,14 @@ async function deletePerson (req, res) { /** * POST Request * - * Enable a Person object by its activation identifier + * Set 'enabled = true' for the Person associated + * with the identifier. * * Required field(s): identifier */ async function enablePersonByActivationLink(req, res){ try { - const personId = await activationModel.getPersonIdByIdentifier(req.body.identifier); + const personId = await activationModel.getPersonIdByIdentifier(req.query.q); if(!personId){ return res.status(401).json({error: 'Activation Link either not valid or expired'}); }