Activate Person by its activation link

This commit is contained in:
xfarrow
2024-03-04 10:37:54 +01:00
parent 5c76a3b061
commit c1ba83d52e
4 changed files with 68 additions and 5 deletions

View File

@ -0,0 +1,33 @@
/*
This code is part of Blink
licensed under GPLv3
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
const knex = require('../utils/knex_config');
/**
* Get a Person's ID by its activation identifier
* @param {*} identifier
* @returns
*/
async function getPersonIdByIdentifier (identifier){
const tuple = await knex('ActivationLink')
.where('identifier', identifier)
.first();
if(tuple){
return tuple.person_id;
}
return null;
}
module.exports = {
getPersonIdByIdentifier
};

View File

@ -128,12 +128,18 @@ async function updatePerson (person, person_id) {
* Deletes a Person specified by its database id.
* @param {*} person_id
*/
async function deletePerson (person_id) {
async function deletePerson (personId) {
await knex('Person')
.where({ id: person_id })
.where({ id: personId })
.del();
}
async function enablePerson (personId) {
await knex('Person')
.where('id', personId)
.update({enabled: true});
}
// Exporting a function
// means making a JavaScript function defined in one
// module available for use in another module.
@ -144,5 +150,6 @@ module.exports = {
getPersonByEmailAndPassword,
registerPerson,
updatePerson,
deletePerson
deletePerson,
enablePerson
};