Answer the question
In order to leave comments, you need to log in
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
]);
}
}
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]']);
});
class PagesController extends Controller
{
public function index()
{
if(!Auth::check()){
return view('enter');
} else {
return view('index');
}
}
public function profile()
{
return view('profile');
}
}
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question