Skip to content

success callback sometimes returns a boolean instead of user info #1

@r8bywork

Description

@r8bywork

Hi,
When using @telegram-login-ultimate/react in my application, the success callback occasionally returns a boolean value instead of the expected user information object. This behavior seems inconsistent and is hard to reproduce reliably.

To Reproduce:
Integrate @telegram-login-ultimate/react in a React app.

Trigger the Telegram login flow.
Observe that in some cases, the success callback receives a boolean instead of the user info object.

Expected behavior
The success callback should always return the Telegram user info object upon successful login.

import { useState } from 'react';
import { type TelegramLoginData, useTelegramLogin } from '@telegram-login-ultimate/react';
import { Button } from '@/shared/ui/button';
import { toast } from '@/shared/ui/sonner';

export const TelegramConnect = () => {
  const [tgUser, setTgUser] = useState<TelegramLoginData>();

  const [openPopup, { isPending }] = useTelegramLogin({
    botId: 'YOUR_BOT_ID',
    onSuccess: (user) => handleSuccess(user),
    onFail: () => handleFail(),
  });

  const handleSuccess = async (user: TelegramLoginData) => {
    setTgUser(user);
    toast.success('Telegram login successful');
  };

  const handleFail = async () => {
    toast.error('Telegram login failed');
  };

  return (
    <Button disabled={isPending} onClick={openPopup}>
      {tgUser ? `@${tgUser.username}` : 'Connect Telegram'}
    </Button>
  );
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions