Я использую https://github.com/invisnik/laravel-steam-auth для своего веб-приложения. Он регистрирует меня без проблем, но когда я хочу go перейти на страницу "мой профиль" или обновить sh, он попросит меня снова войти в систему. Забавно, что когда я добавил {{ print_r(auth()) }}
в моем сеансе просмотра лезвий, он работал как надо.
Мой AuthController:
namespace App\Http\Controllers;
use Invisnik\LaravelSteamAuth\SteamAuth;
use App\User;
use Illuminate\Support\Facades\Auth;
class AuthController extends Controller
{
/**
* The SteamAuth instance.
*
* @var SteamAuth
*/
protected $steam;
/**
* The redirect URL.
*
* @var string
*/
protected $redirectURL = '/';
/**
* AuthController constructor.
*
* @param SteamAuth $steam
*/
public function __construct(SteamAuth $steam)
{
$this->steam = $steam;
}
/**
* Redirect the user to the authentication page
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function redirectToSteam()
{
return $this->steam->redirect();
}
/**
* Get user info and log in
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function handle()
{
if ($this->steam->validate()) {
$info = $this->steam->getUserInfo();
if (!is_null($info)) {
$user = $this->findOrNewUser($info);
auth()->login($user);
return redirect($this->redirectURL); // redirect to site
}
}
return $this->redirectToSteam();
}
/**
* Getting user by info or created if not exists
*
* @param $info
* @return User
*/
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
]);
}
}
Blade:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<title>Steam</title>
</head>
<body>
@if(auth()->check())
<img src="{{ auth()->user()->avatar }}">
<h1>{{ auth()->user()->username }} <a href="{{ route('my.profile') }}">My Profile</a></h1>
<h4>{{ auth()->user()->steamid }}</h4>
<a href="{{ auth()->logout() }}">Log Out</a>
@else
<a href="{{ route('auth.steam') }}"><img src="https://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_01.png"></a>
@endif
</body>
</html>
Не знаю где проблема в том.