How to use passport-telegram-official - 1 common examples

To help you get started, we’ve selected a few passport-telegram-official examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thedevs-network / tgdr / server / passport.ts View on Github external
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.'

passport-telegram-official

Telegram (not official, just the name) authentication strategy for Passport (https://core.telegram.org/widgets/login)

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis

Popular passport-telegram-official functions