/**
  * Validates an incoming response from Steam against the database
  *
  * @return Redirect
  */
 public function validateSteamLogin()
 {
     $validate = SteamLogin::validate();
     if (is_null($validate)) {
         throw new Exception(Lang::get('auth.invalidResponse'));
     } else {
         $steamObject = new SteamId($validate);
         if ($this->users->count() == 0) {
             $user = $this->users->add($this->userDetails($steamObject));
             $roles = $this->roles->getAll();
             foreach ($roles as $role) {
                 $this->users->assignRole($user, $role->id);
             }
             Auth::login($user);
             return Redirect::route('settings')->withFlashNotification(Lang::get('auth.firstLogin'))->withFlashNotificationLevel('success');
         } else {
             $user = $this->users->getFirst('community_id', $steamObject->getSteamId64());
             if (is_null($user)) {
                 throw new Exception(Lang::get('auth.noAccess'));
             } else {
                 if ($user->enabled == 0) {
                     throw new Exception(Lang::get('auth.accountDisabled'));
                 } else {
                     $this->users->edit($user->id, $this->userDetails($steamObject));
                     Auth::login($user);
                     return Redirect::route('dashboard')->withFlashNotification(Lang::get('auth.successfulLogin'))->withFlashNotificationLevel('success');
                 }
             }
         }
     }
 }
Esempio n. 2
0
<?php

define('php-steamlogin', true);
require 'main.php';
$SteamLogin = new SteamLogin(array('username' => '', 'password' => '', 'datapath' => dirname(__FILE__)));
if ($SteamLogin->success) {
    $logindata = $SteamLogin->login();
    /*
    $logindata = array(
    	'steamid' => 'xxx', //64-bit
    	'sessionId' => 'xxx',
    	'cookies' => 'xxx=xxx; yyy=yyy; '
    );
    */
    //You can view steamcommunity.com from created session
    //$SteamLogin->view('http://steamcommunity.com/id/pandeu');
    //Sending tradeoffers: https://github.com/halipso/php-steam-tradeoffers
    if ($SteamLogin->error != '') {
        echo $SteamLogin->error;
    }
} else {
    echo $SteamLogin->error;
}