O
O
Ohjovanni2019-05-05 14:06:39
Laravel
Ohjovanni, 2019-05-05 14:06:39

Why is the authorization through steam not going through?

I use https://github.com/invisnik/laravel-steam-auth
for some reason, authorization passes through once, and if it passes, it can be reset when going to some link that is available only to a registered
AuthController user

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', '[email protected]')->name('auth.steam.handle');
Route::get('auth/steam', '[email protected]')->name('auth.steam');

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

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,
];

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Ohjovanni, 2019-05-06
@Ohjovanni

In the Kernel.php File, try moving the line \Illuminate\Session\Middleware\StartSession::class, from "protected $middlewareGroups = " to "protected $middleware = "

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question