azate / laravel-telegram-login-auth
Laravel Telegram Login Auth
Installs: 13 107
Dependents: 0
Suggesters: 0
Security: 0
Stars: 35
Watchers: 3
Forks: 12
Open Issues: 3
Requires
- php: ^8
- illuminate/config: ^9 || ^10 || ^11
- illuminate/contracts: ^9 || ^10 || ^11
- illuminate/http: ^9 || ^10 || ^11
- illuminate/support: ^9 || ^10 || ^11
README
This package is a Laravel service provider which provides support for Laravel Login and is very easy to integrate with any project that requires Telegram authentication.
Installation
Require this package with composer.
composer require azate/laravel-telegram-login-auth
Laravel >=5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
Copy the package config to your local config with the publish command:
php artisan vendor:publish --provider="Azate\LaravelTelegramLoginAuth\Providers\LaravelServiceProvider" --tag=config
Usage example
Setup information Telegram Login Widget
Not detailed errors
// app/Http/Controllers/AuthController.php namespace App\Http\Controllers; // ... use Azate\LaravelTelegramLoginAuth\TelegramLoginAuth; use Illuminate\Http\Request; // ... public function handleTelegramCallback(TelegramLoginAuth $telegramLoginAuth, Request $request) { if ($user = $telegramLoginAuth->validate($request)) { // ... } // ... }
With detailed errors
// app/Http/Controllers/AuthController.php namespace App\Http\Controllers; // ... use Azate\LaravelTelegramLoginAuth\Contracts\Telegram\NotAllRequiredAttributesException; use Azate\LaravelTelegramLoginAuth\Contracts\Validation\Rules\ResponseOutdatedException; use Azate\LaravelTelegramLoginAuth\Contracts\Validation\Rules\SignatureException; use Azate\LaravelTelegramLoginAuth\TelegramLoginAuth; use Illuminate\Http\Request; // ... public function handleTelegramCallback(TelegramLoginAuth $telegramLoginAuth, Request $request) { try { $user = $telegramLoginAuth->validateWithError($request); } catch(NotAllRequiredAttributesException $e) { // ... } catch(SignatureException $e) { // ... } catch(ResponseOutdatedException $e) { // ... } catch(Exception $e) { // ... } // ... }