diff options
Diffstat (limited to 'src/middleware.ts')
| -rw-r--r-- | src/middleware.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/middleware.ts b/src/middleware.ts index e2814e0..9aa0775 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,10 +1,13 @@ import { Context } from "telegraf"; -import config from "./config"; +import { getPermittedUsers } from "./db"; const auth = async (ctx: Context, next: () => Promise<void>): Promise<void> => { const userId = ctx.message?.from.id; - if (!userId || !config.tgUserIds.includes(userId)) { + const tgUsers = await getPermittedUsers(); + const tgUserIds = tgUsers.map(u => u.id); + + if (!userId || !tgUserIds.includes(userId)) { ctx.reply("Käyttäjälläsi ei ole oikeuksia startata HommaBottia."); } else { await next(); |
