jxri / laravel-telegram-auth
Laravel Telegram Login Auth
dev-master
2020-09-19 04:52 UTC
Requires
- php: >=7.2
- illuminate/http: ~5.6|~5.7|~5.8|^6.0|^7.0
- illuminate/support: ~5.6|~5.7|~5.8|^6.0|^7.0
- nesbot/carbon: ^1.32|^2.32
This package is auto-updated.
Last update: 2024-05-19 12:37:59 UTC
README
This package is a Laravel 5 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\TelegramLoginServiceProvider"
Usage example
Setup information Telegram Login Widget
In routes/web.php
:
Route::get('auth/telegram/callback', 'AuthController@handleTelegramCallback')->name('auth.telegram.handle');
In AuthController
:
namespace App\Http\Controllers; use Azate\LaravelTelegramLoginAuth\TelegramLoginAuth; class AuthController extends Controller { /** * @var TelegramLoginAuth */ protected $telegram; /** * AuthController constructor. * * @param TelegramLoginAuth $telegram */ public function __construct(TelegramLoginAuth $telegram) { $this->telegram = $telegram; } /** * Get user info and log in (hypothetically) * * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function handleTelegramCallback() { if ($this->telegram->validate()) { $user = $this->telegram->user(); // } return redirect('/'); } }