From b8cba2595f7099afb3e261836af80ce3bccf90eb Mon Sep 17 00:00:00 2001 From: Pouria Ezzati Date: Wed, 11 Oct 2017 21:34:05 +0330 Subject: [PATCH] check if username exists before using methods --- handlers/messages/addUser.js | 1 + handlers/middlewares/addedToGroup.js | 1 + 2 files changed, 2 insertions(+) diff --git a/handlers/messages/addUser.js b/handlers/messages/addUser.js index ef8e063..07331fd 100644 --- a/handlers/messages/addUser.js +++ b/handlers/messages/addUser.js @@ -29,6 +29,7 @@ const addUserHandler = async (ctx, next) => { isAdmin: user && user.status === 'admin', isMaster: user && user.id === Number(master) || + user.username && user.username.toLowerCase() === String(master).replace('@', '').toLowerCase(), user: newUser, diff --git a/handlers/middlewares/addedToGroup.js b/handlers/middlewares/addedToGroup.js index a530c30..5a4a631 100644 --- a/handlers/middlewares/addedToGroup.js +++ b/handlers/middlewares/addedToGroup.js @@ -11,6 +11,7 @@ const addedToGroupHandler = async (ctx, next) => { const msg = ctx.message; const { telegram } = ctx; const isMaster = ctx.from.id === Number(master) || + ctx.from.username && ctx.from.username.toLowerCase() === String(master).replace('@', '').toLowerCase();