Skip to content

Commit

Permalink
Merge pull request #25 from kanalumaddela/master
Browse files Browse the repository at this point in the history
pull changes from master
  • Loading branch information
kanalumaddela authored Oct 7, 2018
2 parents b48330b + 31ddd68 commit 5d78252
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Make sure you have made/performed your migrations along with updating your `User

Thanks to these libs which led me to make this
- https://github.com/Ehesp/Steam-Login (Parts of code used and re-purposed for laravel)
- https://github.com/invisnik/laravel-steam-auth (Getting me to create a laravel steam auth that isn't shit, your code *totally* doesn't look like Ehesp's you cuck. For others reading this compare the code, invisnik can't even give proper credit)
- https://github.com/invisnik/laravel-steam-auth (Getting me to create a laravel steam auth that isn't bad, couldn't bother giving credit to Ehesp after *stealing* his code)
10 changes: 5 additions & 5 deletions src/SteamLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function __construct(Application $app)
$this->app = $app;
$this->request = $app->request;
$this->guzzle = new GuzzleClient();
$this->https = $this->request->server('HTTP_X_FORWARDED_PROTO') == 'https' ?? isset($_SERVER['https']);
$this->https = $this->request->server('HTTP_X_FORWARDED_PROTO') === 'https' ?? isset($_SERVER['https']);

$previousPage = url()->previous();
$this->loginRoute = route(Config::get('steam-login.routes.login'));
Expand Down Expand Up @@ -150,11 +150,11 @@ public function setReturnUrl(string $return)
/**
* Build the steam openid login URL.
*
* @param null $return
* @param string|null $return
*
* @return string
*/
public function createLoginUrl($return = null): string
public function createLoginUrl(?string $return = null): string
{
$params = [
'openid.ns' => self::OPENID_SPECS,
Expand Down Expand Up @@ -269,7 +269,7 @@ public function validate(): ?string

preg_match('#^https?://steamcommunity.com/openid/id/([0-9]{17,25})#', $this->request->input('openid_claimed_id'), $matches);
$steamid = is_numeric($matches[1]) ? $matches[1] : 0;
$steamid = preg_match("#is_valid\s*:\s*true#i", $result) == 1 ? $steamid : null;
$steamid = preg_match("#is_valid\s*:\s*true#i", $result) === 1 ? $steamid : null;

return $steamid;
}
Expand All @@ -295,6 +295,6 @@ public function loginButton(string $type = 'small'): string
*/
public static function button(string $type = 'small'): string
{
return 'https://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_0'.($type == 'small' ? 1 : 2).'.png';
return 'https://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_0'.($type === 'small' ? 1 : 2).'.png';
}
}
7 changes: 0 additions & 7 deletions src/SteamLoginServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

class SteamLoginServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap any application services.
*
Expand Down
12 changes: 6 additions & 6 deletions src/SteamUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public function __construct($steamId, GuzzleClient $guzzle = null)

$this->fluent = new Fluent($this->attributes);

$this->method = Config::get('steam-login.method', 'xml') == 'api' ? 'api' : 'xml';
$this->profileDataUrl = $this->method == 'xml' ? $this->attributes->profileDataUrl : sprintf(self::STEAM_PLAYER_API, Config::get('steam-login.api_key'), $this->attributes->steamId);
$this->method = Config::get('steam-login.method', 'xml') === 'api' ? 'api' : 'xml';
$this->profileDataUrl = $this->method === 'xml' ? $this->attributes->profileDataUrl : sprintf(self::STEAM_PLAYER_API, Config::get('steam-login.api_key'), $this->attributes->steamId);
}

/**
Expand Down Expand Up @@ -186,7 +186,7 @@ public function getUserInfo(): self
private function userInfo()
{
$this->response = $this->guzzle->get($this->profileDataUrl, ['connect_timeout' => Config::get('steam-login.timeout')]);
$data = $this->method == 'xml' ? simplexml_load_string($this->response->getBody(), 'SimpleXMLElement', LIBXML_NOCDATA) : json_decode($this->response->getBody());
$data = $this->method === 'xml' ? simplexml_load_string($this->response->getBody(), 'SimpleXMLElement', LIBXML_NOCDATA) : json_decode($this->response->getBody());

switch ($this->method) {
case 'api':
Expand All @@ -196,7 +196,7 @@ private function userInfo()
$this->attributes->name = $data->personaname;
$this->attributes->realName = isset($data->realname) ? $data->realname : null;
$this->attributes->profileUrl = $data->profileurl;
$this->attributes->privacyState = $data->communityvisibilitystate == 3 ? 'Public' : 'Private';
$this->attributes->privacyState = $data->communityvisibilitystate === 3 ? 'Public' : 'Private';
$this->attributes->visibilityState = $data->communityvisibilitystate;
$this->attributes->isOnline = $data->personastate != 0;
$this->attributes->onlineState = isset($data->gameid) ? 'In-Game' : ($data->personastate != 0 ? 'Online' : 'Offline');
Expand All @@ -212,10 +212,10 @@ private function userInfo()
$this->attributes->name = (string) $data->steamID;
$this->attributes->realName = isset($data->realName) ? $data->realName : null;
$this->attributes->profileUrl = isset($data->customURL) ? 'https://steamcommunity.com/id/'.$data->customURL : $this->attributes->accountUrl;
$this->attributes->privacyState = $data->privacyState == 'public' ? 'Public' : 'Private';
$this->attributes->privacyState = $data->privacyState === 'public' ? 'Public' : 'Private';
$this->attributes->visibilityState = (int) $data->visibilityState;
$this->attributes->isOnline = $data->onlineState != 'offline';
$this->attributes->onlineState = $data->onlineState == 'in-game' ? 'In-Game' : ucfirst($data->onlineState);
$this->attributes->onlineState = $data->onlineState === 'in-game' ? 'In-Game' : ucfirst($data->onlineState);
// todo: stateMessage
$this->attributes->avatarSmall = $this->attributes->avatarIcon = (string) $data->avatarIcon;
$this->attributes->avatarMedium = (string) $data->avatarMedium;
Expand Down

0 comments on commit 5d78252

Please sign in to comment.