/** * Constructs a new base controller. */ public function __construct() { $this->lrs = Helpers::getLrsFromAuth(); list($username, $password) = Helpers::getUserPassFromAuth(); $this->client = Helpers::getClient($username, $password); }
/** * Gets the Lrs associated with the given username and password. * @param String $username * @param String $password * @return Lrs */ static function getLrsFromUserPass($username, $password) { $client = Helpers::getClient($username, $password); $lrs = $client === null ? null : \Lrs::find($client->lrs_id); if ($lrs === null) { throw new Exceptions\Exception('Unauthorized request.', 401); } return $lrs; }