invisnik / laravel-steam-auth

Laravel Steam Auth
MIT License
172 stars 67 forks source link

validate() fails #53

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hey guys, I am really confused by this one. Having used this library on a couple projects and I never ran into such a problem. This is possibly a mistake on my side after not having used Laravel in a while now. I'm using Laravel 5.4 and PHP 7.1.4.

When clicking on the "Login through Steam" button it will redirect me to Steam as usual. After submitting my credentials over at Steam I get redirected back to my site. Now the URL will look like this: https://steam.local/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Flogin&openid.claimed_id=http%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F.......................................................................................................................................

No User has been created and obviously I have not been logged in. I simply can't figure out the problem and i need your help guys.

web.php (Routes)

Route::get('/', function() { return redirect(Auth::check() ? '/home' : '/steamlogin'); });
Route::get('login', function() { return Auth::check() ? redirect('/home') : view('steamlogin'); })->name('steamlogin');
Route::get('login-through-steam', 'AuthController@steamlogin')->name('loginThroughSteam');
Route::group(['middleware' => 'auth.steam'], function () {
Route::get('home', function() { return view('home'); })->name('home');
});

AuthController->steamlogin()

public function steamlogin()
    {
        if ($this->steam->validate()) {
            $info = $this->steam->getUserInfo();
            if (!is_null($info)) {
                $user = User::where('steamid', '=', $info->steamID64)->first();
                $new = is_null($user) ? true : false;
                if (is_null($user)) {
                    $user = User::create([
                        'steamid'        => $info->steamID64,
                        'steam_avatar'        => $info->avatarfull,
                        'steam_name'        => $info->personaname
                    ]);
                }
                else {
                    $user->update([
                        'steam_avatar' => $info->avatarfull,
                        'steam_name' => $info->personaname,
                    ]);
                }
                Auth::login($user, true);
                return redirect('/');
            }
        }
        return $this->steam->redirect(); // redirect to Steam login page
    }

Steam.Auth (Middleware)

public function handle($request, Closure $next)
    {
        if (Auth::guest()) {
            return redirect('/login');
        }
        return $next($request);
    }

debug_steam_auth

php artisan route:list

+--------+----------+------------------------------+----------------------+---------------------------------------------------------------+------------------------+
| Domain | Method   | URI                          | Name                 | Action                                                        | Middleware             |
+--------+----------+------------------------------+----------------------+---------------------------------------------------------------+------------------------+
|        | GET|HEAD | /                            |                      | Closure                                                       | web                    |
|        | GET|HEAD | api/user                     |                      | Closure                                                       | api,auth:api           |
|        | GET|HEAD | home                         | home                 | Closure                                                       | web,auth.steam         |
|        | GET|HEAD | login-through-steam          | loginThroughSteam    | App\Http\Controllers\AuthController@steamlogin                | web                    |
|        | POST     | logout                       | logout               | Closure                                                       | web,auth.steam         |
|        | GET|HEAD | steamlogin                   | steamlogin           | Closure                                                       | web                    |
+--------+----------+------------------------------+----------------------+---------------------------------------------------------------+------------------------+
ghost commented 7 years ago

I ended up with setting up the Steam adapter for Socialite which is working just fine with exactly the same login method. I am even more confused now. Any help is appreciated.