diff --git a/lib/middleware.js b/lib/middleware.js index 6134486..e481614 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -68,10 +68,12 @@ const checkAccountLimits = async(req, res, next) => { ...req.locals, account_sid: account.account_sid, webhook_secret: account.webhook_secret, - registration_hook_url: account.registration_hook.url, - registration_hook_method: account.registration_hook.method, - registration_hook_username: account.registration_hook.username, - registration_hook_password: account.registration_hook.password + ...(account.registration_hook && { + registration_hook_url: account.registration_hook.url, + registration_hook_method: account.registration_hook.method, + registration_hook_username: account.registration_hook.username, + registration_hook_password: account.registration_hook.password + }) }; debug(account, `checkAccountLimits: retrieved account for realm: ${realm}`); } diff --git a/lib/register-authenticator.js b/lib/register-authenticator.js index 0357128..60b03ed 100644 --- a/lib/register-authenticator.js +++ b/lib/register-authenticator.js @@ -189,10 +189,7 @@ const digestChallenge = async(req, res, next) => { const {stats} = req.srf.locals; const { account_sid, - registration_hook_url, - registration_hook_method, - registration_hook_username, - registration_hook_password, + registration_hook, webhook_secret } = req.locals; // Cannot detect account, reject register request