Skip to content

Commit

Permalink
Release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
invisnik committed Mar 20, 2015
1 parent 6bb372f commit 53016fa
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 49 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This package is a Laravel 5 service provider which provides Steam OpenID and is
Add this to your composer.json file, in the require object:

```javascript
"invisnik/laravel-steam-auth": "dev-master"
"invisnik/laravel-steam-auth": "~1.0.0"
```

After that, run composer install to install the package.
Expand All @@ -19,6 +19,14 @@ Add the service provider to `app/config/app.php`, within the `providers` array.
)
```

```php
'aliases' => array(
// ...
'SteamAuth' => 'Invisnik\LaravelSteamAuth\Facades\SteamAuth',
)
```
You how have access to the `SteamAuth` facade.

## Usage
```php
use Invisnik\LaravelSteamAuth\SteamAuth;
Expand All @@ -37,10 +45,9 @@ class SteamController extends Controller {

public function getLogin()
{
$this->steam->Init();

if( $this->steam->isLoginIn()){
return $this->steam->SteamID; //returns the user steamid
if( $this->steam->validate()){
return $this->steam->getSteamId(); //returns the user steamid
}else{
return $this->steam->redirect(); //redirect to steam login page
}
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
"psr-4": {
"Invisnik\\LaravelSteamAuth\\": "src"
}
},
"minimum-stability": "dev"
}
}
16 changes: 16 additions & 0 deletions src/Facades/SteamAuth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php namespace Invisnik\LaravelSteamAuth\Facades;

use Illuminate\Support\Facades\Facade;

class SteamAuth extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'steamauth';
}
}
51 changes: 20 additions & 31 deletions src/SteamAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,58 @@

use Invisnik\LaravelSteamAuth\LightOpenID;

class SteamAuth {
class SteamAuth implements SteamAuthInterface {

private $OpenID;
private $OnLoginCallback;
private $OnLoginFailedCallback;

public $SteamID = false;

public function __construct()
{
$Server = $_SERVER['SERVER_NAME'];
$this->OpenID = new LightOpenID($Server);
$server = $_SERVER['SERVER_NAME'];
$this->OpenID = new LightOpenID($server);
$this->OpenID->identity = 'https://steamcommunity.com/openid';

$this->OnLoginCallback = function(){};
$this->OnLoginFailedCallback = function(){};
}

public function __call($closure, $args)
{
return call_user_func_array($this->$closure, $args);
$this->init();
}

public function Init()
private function init()
{
if($this->OpenID->mode == 'cancel'){
$this->OnLoginFailedCallback(function(){
$this->SteamID = false;
});

$this->SteamID = false;

}else if($this->OpenID->mode){

if($this->OpenID->validate()){

$this->SteamID = basename($this->OpenID->identity);

}else{
$this->OnLoginFailedCallback(function(){
$this->SteamID = false;
});

$this->SteamID = false;

}

}
}

public function isLoginIn()
public function validate()
{
return $this->SteamID ? true : false;
}

public function redirect()
{
return redirect($this->getLoginURL());
return redirect($this->url());
}

public function getLoginURL()
public function url()
{
return $this->OpenID->authUrl();
}

public function SetOnLoginCallback($OnLoginCallback)
{
$this->OnLoginCallback = $OnLoginCallback;
}

public function SetOnLoginFailedCallback($OnLoginFailedCallback)
{
$this->OnLoginFailedCallback = $OnLoginFailedCallback;
public function getSteamId(){
return $this->SteamID;
}

}
10 changes: 10 additions & 0 deletions src/SteamAuthInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Invisnik\LaravelSteamAuth;

interface SteamAuthInterface
{
public function url();
public function redirect();
public function validate();
public function getSteamId();
}
14 changes: 2 additions & 12 deletions src/SteamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,16 @@

class SteamServiceProvider extends ServiceProvider {

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{

}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app['steam'] = $this->app->share(
$this->app['steamauth'] = $this->app->share(
function () {
return new \SteamAuth();
return new SteamAuth();
}
);
}
Expand Down

0 comments on commit 53016fa

Please sign in to comment.