@Ohjovanni

Почему не проходит авторизация через steam?

Использую https://github.com/invisnik/laravel-steam-auth
почему-то авторизация проходит через раз, а если проходит то может сброситься при переходе на какую-нибудь ссылку которая доступна только зарегистрированному пользователю
AuthController
namespace App\Http\Controllers;

use Invisnik\LaravelSteamAuth\SteamAuth;
use App\User;
use Illuminate\Support\Facades\Auth;

class AuthController extends Controller
{
    protected $steam;

    protected $redirectURL = '/';

    public function __construct(SteamAuth $steam)
    {
        $this->steam = $steam;
    }

    public function redirectToSteam()
    {
        return $this->steam->redirect();
    }

    public function handle()
    {
        if ($this->steam->validate()) {
            $info = $this->steam->getUserInfo();

            if (!is_null($info)) {
                $user = $this->findOrNewUser($info);

                Auth::login($user, true);

                return redirect($this->redirectURL); // redirect to site
            }
        }
        return $this->redirectToSteam();
    }

    protected function findOrNewUser($info)
    {
        $user = User::where('steamid', $info->steamID64)->first();
        if (!is_null($user)) {
            return $user;
        }
        return User::create([
            'username' => $info->personaname,
            'avatar'   => $info->avatarfull,
            'steamid'  => $info->steamID64
        ]);
    }
}

web.php
Route::get('auth/steam/handle', 'AuthController@handle')->name('auth.steam.handle');
Route::get('auth/steam', 'AuthController@redirectToSteam')->name('auth.steam');

Route::get('/', 'PagesController@index')->name('index');
Route::group(['middleware' => ['auth']], function () {
    Route::get('/profile', ['as' => 'changes', 'uses' =>'PagesController@profile']);
});

PagesController.php
class PagesController extends Controller
{
    public function index()
    {
        if(!Auth::check()){
            return view('enter');
        } else {
            return view('index');
        }
    }
    public function profile()
    {
        return view('profile');
    }
}

steam-auth.php
return [
    'redirect_url' => '/auth/steam/handle',
    //'realm' => 'redirected.com',
    'api_key' => env('STEAM_API_KEY', ''),
    'https' => false,
];
  • Вопрос задан
  • 155 просмотров
Решения вопроса 1
@Ohjovanni Автор вопроса
В Файле Kernel.php нужно попробовать перенести строку \Illuminate\Session\Middleware\StartSession::class, из "protected $middlewareGroups = " в "protected $middleware = "
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы