Pre registration user deny access


So i try to set pre user registration action that will check to company database before registering new account.
From log activity i can confirm that the action is working, the problem is event when its return api.accrs.deny user can still pass the registration process.

Here is my code.

is there any extra step to do?
const mysql = require(‘mysql’);

exports.onExecutePreUserRegistration = async (event, api) => {
const connection = mysql.createConnection({
host: xxxxx,
user: ‘xxxx’,
password: xxxx,
database: xxxx,
port: xxx


const checkEmployee = ‘SELECT AS id, AS nickname, Users.employeeId AS employeeId, AS email, AS contactEmail FROM db_employee.Employees Employee LEFT JOIN db_auth.Users Users ON = Users.employeeId LEFT JOIN db_employee.Contacts Contacts ON = Contacts.employeeId WHERE = ?’;

await connection.query(checkEmployee, [], async function(err, results) {
try {
if (err) return api.access.deny(“sql_error”,err);
if (results.length < 1) {api.access.deny(“employee_not_found”,“employee data not found”);}
} catch (e){
api.access.deny(‘Could not create user doc’);

Hi @fakhrulraharjo

You are missing return statement in the catch(e) block.

Let us know if this helps


Okay leet me try it and give u an update