updated activationlink method. Now it is GET

This commit is contained in:
xfarrow 2024-03-04 12:26:06 +01:00
parent c1ba83d52e
commit 4cd0772dd7
3 changed files with 8 additions and 6 deletions

View File

@ -56,7 +56,7 @@ publicRoutes.post('/register', personRoutes.registerPerson);
publicRoutes.post('/login', personRoutes.login); publicRoutes.post('/login', personRoutes.login);
publicRoutes.get('/person/:id/details', personRoutes.getPerson); publicRoutes.get('/person/:id/details', personRoutes.getPerson);
publicRoutes.get('/organization/:id', organizationRoutes.getOrganization); publicRoutes.get('/organization/:id', organizationRoutes.getOrganization);
publicRoutes.post('/person/activation', personRoutes.enablePersonByActivationLink); publicRoutes.get('/person/activation', personRoutes.enablePersonByActivationLink);
const protectedRoutes = express.Router(); const protectedRoutes = express.Router();
protectedRoutes.use(jwtUtils.verifyToken); protectedRoutes.use(jwtUtils.verifyToken);

View File

@ -16,12 +16,13 @@ const knex = require('../utils/knex_config');
/** /**
* Get a Person's ID by its activation identifier * Get a Person's ID by its activation identifier
* @param {*} identifier * @param {*} identifier
* @returns * @returns The Person's ID associated with the identifier if present,
* null otherwise
*/ */
async function getPersonIdByIdentifier (identifier){ async function getPersonIdByIdentifier (identifier){
const tuple = await knex('ActivationLink') const tuple = await knex('ActivationLink')
.where('identifier', identifier) .where('identifier', identifier)
.first(); .first();
if(tuple){ if(tuple){
return tuple.person_id; return tuple.person_id;
} }

View File

@ -228,13 +228,14 @@ async function deletePerson (req, res) {
/** /**
* POST Request * POST Request
* *
* Enable a Person object by its activation identifier * Set 'enabled = true' for the Person associated
* with the identifier.
* *
* Required field(s): identifier * Required field(s): identifier
*/ */
async function enablePersonByActivationLink(req, res){ async function enablePersonByActivationLink(req, res){
try { try {
const personId = await activationModel.getPersonIdByIdentifier(req.body.identifier); const personId = await activationModel.getPersonIdByIdentifier(req.query.q);
if(!personId){ if(!personId){
return res.status(401).json({error: 'Activation Link either not valid or expired'}); return res.status(401).json({error: 'Activation Link either not valid or expired'});
} }