Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as passport from 'passport';
import config from './config';
import TelegramStratagy from 'passport-telegram-official';
import * as PassportJwt from 'passport-jwt';
import * as authQuery from './db/authQuery';
import CustomError from './helpers/customError';
passport.use(
new TelegramStratagy(
{
botToken: config.bot_token,
},
async (profile, cb) => {
try {
const user = await authQuery.create(profile.id, {
first_name: profile.first_name.slice(0, 32),
last_name: profile.last_name ? profile.last_name.slice(0, 32) : null,
telegram_id: profile.id,
username: profile.username,
});
if (user.banned) {
return cb(
new CustomError(
'You have been banned. Contact support for more info.'