2017 © Pedro Peláez
 

library steam-auth

Laravel Steam Auth

image

eliuflorez/steam-auth

Laravel Steam Auth

  • Saturday, January 23, 2016
  • by EliuFlorez
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

This package is a Laravel 5 service provider which provides support for Steam OpenID and is very easy to integrate with any project that requires Steam authentication., (*1)

Installation Via Composer

Add this to your composer.json file, in the require object:, (*2)

"eliuflorez/steam-auth": "1.*"

After that, run composer install to install the package., (*3)

Add the service provider to app/config/app.php, within the providers array., (*4)

'providers' => [
    // ...
    EliuFlorez\SteamAuth\SteamServiceProvider::class,
]

Lastly, publish the config file., (*5)

php artisan vendor:publish

Usage example

In config/steam-auth.php, (*6)

return [

    /*
     * Redirect URL after login
     */
    'redirect_url' => '/login',

    /*
     *  API Key (http://steamcommunity.com/dev/apikey)
     */
    'api_key' => 'Your API Key'

];

In routes.php, (*7)

get('login', 'AuthController@login');

In AuthController, (*8)

namespace App\Http\Controllers;

use EliuFlorez\SteamAuth\SteamAuth;
use App\User;
use Auth;

class AuthController 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 = User::where('steamid', $info->getSteamID64())->first();
                if (!is_null($user)) {
                    Auth::login($user, true);
                    return redirect('/'); // redirect to site
                }else{
                    $user = User::create([
                        'username' => $info->getNick(),
                        'avatar'   => $info->getProfilePictureFull(),
                        'steamid'  => $info->getSteamID64()
                    ]);
                    Auth::login($user, true);
                    return redirect('/'); // redirect to site
                }
            }
        } else {
            return $this->steam->redirect(); // redirect to Steam login page
        }
    }
}

The Versions

23/01 2016

dev-master

9999999-dev

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Eliu Florez

laravel auth steam

23/01 2016

1.0

1.0.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Eliu Florez

laravel auth steam