/**
* @module Dao
*/
const Dao = require('./dao');
module.exports = class bioDao extends Dao {
/**
* Used to check if the user has answered if he wants to use biometric login.
* @param {string} tokenId Unique device ID.
* @param {function} callback Function callback.
*/
getOne(tokenId, callback) {
const val = tokenId;
super.query('SELECT * FROM biometric WHERE expoToken = ?', val, callback);
}
/**
* Method to see if the tokenId exists in the DB when he logs in.
* @param {string} tokenId Unique device ID.
* @param {function} callback Function callback.
*/
checkExist(tokenId, callback) {
const val = tokenId;
super.query(
'SELECT EXISTS (SELECT * FROM biometric WHERE expoToken = ?) AS exist',
[val],
callback
);
}
/**
* Method to insert a users unique devide ID into biometric table.
* @param {string} tokenId Unique device ID
* @param {function} callback Function callback
*/
insertToken(tokenId, callback) {
const val = tokenId;
super.query('INSERT INTO biometric (expoToken) VALUES (?)', val, callback);
}
/**
* Method to change the biometri value. In case the user wants to turn off/on biometric login.
* @param {jsonObject} json Object containing option and tokenId.
* @param {function} callback Function callback
*/
setBiometric(json, callback) {
const val = [json.option, json.tokenId];
super.query('UPDATE biometric SET biometri=? WHERE expoToken=?', val, callback);
}
/**
* First time the user logs in he gets asked if the wants to use biometric login if its available
* This method changes the value of firstPrompt after the users answers the question.
* @param {jsonObject} json Object containing option and tokenId.
* @param {function} callback Function callback
*/
setFirstPrompt(json, callback) {
const val = [json.option, json.tokenId];
super.query('UPDATE biometric SET firstPrompt=? WHERE expoToken=?', val, callback);
}
};