HummingBirdAnimeClient/src/Aviat/AnimeClient/Auth/HummingbirdAuth.php

66 lines
1.2 KiB
PHP
Raw Normal View History

2015-09-17 23:11:18 -04:00
<?php
namespace Aviat\AnimeClient\Auth;
use Aviat\Ion\Di\ContainerInterface;
use Aviat\AnimeClient\Model\Anime as AnimeModel;
2015-10-09 14:34:55 -04:00
/**
* Hummingbird API Authentication
*/
2015-09-17 23:11:18 -04:00
class HummingbirdAuth {
use \Aviat\Ion\Di\ContainerAware;
/**
* Anime API Model
*
* @var AnimeModel
*/
protected $model;
/**
* Session object
*
* @var Aura\Session\Segment
*/
protected $session;
/**
* Constructor
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->setContainer($container);
2015-10-09 14:34:55 -04:00
$this->session = $container->get('session')
2015-09-17 23:11:18 -04:00
->getSegment(__NAMESPACE__);
$this->model = new AnimeModel($container);
}
2015-10-09 14:34:55 -04:00
/**
* Make the appropriate authentication call,
* and save the resulting auth token if successful
*
* @param string $username
* @param string $password
* @return boolean
*/
2015-09-17 23:11:18 -04:00
public function authenticate($username, $password)
{
2015-10-09 14:34:55 -04:00
return $this->model->authenticate();
2015-09-17 23:11:18 -04:00
}
2015-10-09 14:34:55 -04:00
/**
* Retrieve the authentication token from the session
*
* @return string
*/
2015-09-17 23:11:18 -04:00
public function get_auth_token()
{
2015-10-09 14:34:55 -04:00
return $this->session->get('auth_token');
2015-09-17 23:11:18 -04:00
}
}
// End of HummingbirdAuth.php