Skip to content

Commit

Permalink
This PR add username validation
Browse files Browse the repository at this point in the history
On all commands that use userMiddleware
  • Loading branch information
grunch committed Jul 26, 2023
1 parent 802bc95 commit 0d022d2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bot/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const validateUser = async (ctx, start) => {
const tgUser = ctx.update.callback_query
? ctx.update.callback_query.from
: ctx.update.message.from;
// We need to make sure the user has a username
if (!tgUser.username) {
return await messages.nonHandleErrorMessage(ctx);
}
let user = await User.findOne({ tg_id: tgUser.id });

if (!user && start) {
Expand Down

0 comments on commit 0d022d2

Please sign in to comment.