invisnik / laravel-steam-auth

Laravel Steam Auth
MIT License
172 stars 69 forks source link

Cannot access scope #73

Closed Rexeh closed 6 years ago

Rexeh commented 6 years ago

Having some issues with the plugin on PHP 7 and protected scopes. Using your example with some modifications, but those are not causing the issues.

Locally, development works perfect, on deployment to production it is no longer working, failing with the below

FatalThrowableError in SteamAuthController.php line 56: Cannot access protected property Invisnik\LaravelSteamAuth\SteamInfo::$steamID64

`<?php namespace App\Http\Controllers\Auth;

//use App\Http\Requests\Request; use App\Http\Controllers\Controller; use App\User; use Illuminate\Support\Facades\Auth; use Request; use Invisnik\LaravelSteamAuth\SteamAuth;

class SteamAuthController extends Controller {

/**
 * @var SteamAuth
 */
private $steam;

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

public function login()
{
    if ($this->steam->validate()) {

        $info = $this->steam->getUserInfo();

        if (!is_null($info)) {

            $user = $this->findOrNewUser($info);

            $user->ip_address = Request::getClientIp();
            $user->save();

            Auth::login($user, true);

            return self::redirectvalid();

        } else {
            return $this->steam->redirect(); // redirect to Steam login page
        }
    }
    else {
        return $this->steam->redirect(); // redirect to Steam login page
    }
}

protected function findOrNewUser($info)
{
    $user = User::where('steamid', $info->steamID64)->first();

    if (!is_null($user)) {
        return $user;
    }

    $user = User::create([
        'name' => $info->personaname,
        'avatar' => $info->avatarfull,
        'steamid' => $info->steamID64
    ]);

    $user->setAvatar(file_get_contents($info->avatarfull));

    return $user;
}

public function redirect() {

    $playerUID = User::where('uid', '=', Auth::user()->uid)->first();
    return redirect('/player/'. $playerUID->uid); // redirect to site

}

public function redirectvalid() {

    $playerUID = User::where('uid', '=', Auth::user()->uid)->first();
    return redirect('/player/'. $playerUID->uid); // redirect to site

}

}`

Any ideas what is causing this?

dhurley94 commented 6 years ago

Have you tried adjusting the SSL settings mentioned in the Readme? This resolve the issue for me.

Rexeh commented 6 years ago

Issue has been resolved. Code was actually all sound, however deployment script wasn't doing composer update. So was running new code on a old library!

So for future reference, if you see this check the installed vendor is the correct version on your server.