Skip to content
Stanislav Opletal edited this page Jul 27, 2017 · 2 revisions

Login

Buttons

Relisoft\Steam\Src\Login\Button::rectangle()

Rectangle

Relisoft\Steam\Src\Login\Button::square()

Square

Login process

Login class instance

Login object using session to store states between the application but you have to add session source by your own. This i made because i am using nette framework and it's have own session api.

$this->login = new Login($this->session->getSection("steam"));
OR
$this->login = new Login($_SESSION);

Authentication

Using login object whitch we created above and use function auth

$return = $login->auth();

What it returns? Its return 3 type of states:

if($object) //If success returning STEAM ID
{
      $this->flashMessage("successfuly logged in $object");
      $this->redirect("single",$object);
}
elseif($object == $login::FAILED)
{
      $this->flashMessage("Steam is not logged in!");
      $this->redirect("this");
}
elseif($object == $login::CANCEL)
{
      $this->flashMessage("Cancel by user");
      $this->redirect("this");
}

And that's it... Your login is good. But wait... We forgot for one think. If someone call your function it will be every time redirecting him into steam. So easy add one if and everything is complete.

if($login->isLogged())
{
     $this->flashMessage("User is logged.");
     $this->redirect("single",$this->session->getSection("steam")->user);
}
else
{
     $object = $login->auth();

     if($object)
     {
           $this->flashMessage("successfuly logged in $object");
           $this->redirect("single",$object);
     }
     elseif($object == $login::FAILED)
     {
           $this->flashMessage("Steam is not logged in!");
           $this->redirect("this");
     }
     elseif($object == $login::CANCEL)
     {
           $this->flashMessage("Cancel by user");
           $this->redirect("this");
     }
}

Clone this wiki locally