mirror of
https://github.com/xfarrow/blink
synced 2025-03-19 12:40:03 +01:00
updated activationlink method. Now it is GET
This commit is contained in:
parent
c1ba83d52e
commit
4cd0772dd7
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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'});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user