invisnik / laravel-steam-auth

Laravel Steam Auth
MIT License
172 stars 67 forks source link

validate() fails due to steam api 403 error #11

Closed JABirchall closed 8 years ago

JABirchall commented 8 years ago

The steam API request on line 157 is returning 403 error causing a login loop..

I narrowed the issue down the \Config::get('steam-auth.api_key') is not getting the api-key or putting it in the request URL. Replacing this with the API resolves the issue.

norfair00 commented 8 years ago

You found the solution?

JABirchall commented 8 years ago

Yeah, your \Config call does not aquired the api key. my fix was just just replace the whole call with the API key

I also made other changes to the code example i made all the Protected members in steaminfo.php public for my own flexability.

I would also suggest you use my alternate method of validating if a user is registered to create etc, as it also supports dual authentication if some devs wish to have that flexibility.

public function steamAuth(SteamAuth $steam)
{
    if($steam->validate()) {
        $steamInfo = $steam->getUserInfo();

        $validator = Validator::make((array)$steamInfo, [
            'steamID64' => 'required|numeric',
            'nick' => 'required',
            'profileURL' => 'required|url',
            'profilePicture' => 'url',
        ]);

        if($validator->fails())
            return $steam->redirect();

        if(Auth::check() === TRUE)// Dual Auth compatibility
            $user = Auth::User();
        else
            $user = User::firstOrNew(['steamId' => $steamInfo->steamID64]);

        $user->username = $user->username ?? $steamInfo->nick; //PHP7.0 >= ONLY use isset($user->username) ? $user->username : $steamInfo->nick; if PHP version < 7.0.0.0.0.0.0.0.0.0.*
        $user->steamId = $steamInfo->steamID64;
        $user->profilePicture = $steamInfo->profilePicture;
        $user->profilePictureLarge = $steamInfo->profilePictureFull;
        $user->profileURL = $steamInfo->profileURL;
        $user->save();

        if($user->exists === true)
            Auth::login($user, true);
        else
            return $steam->redirect();

    }else
        return $steam->redirect();
    return redirect('/');
}
Mahmoudz commented 8 years ago

+1

invisnik commented 8 years ago

28