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.
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"
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('/');
}
}