Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 1 Examples of "passport-telegram-official in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'passport-telegram-official' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

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.'

Is your System Free of Underlying Vulnerabilities?
Find Out Now