mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Activate Person by its activation link
This commit is contained in:
33
backend/apis/nodejs/src/models/activation_model.js
Normal file
33
backend/apis/nodejs/src/models/activation_model.js
Normal 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
|
||||
};
|
@ -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
|
||||
};
|
||||
|
Reference in New Issue
Block a user