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.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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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'});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user