Jimmy Monin 58ffd500e6 Upgrade LBCAlerte to version 3.3
Add upgrade script
2016-11-26 19:25:53 +01:00

31 lines
756 B
PHP

<?php
namespace Auth;
require_once __DIR__."/Abstract.php";
class ApiKey extends AuthAbstract
{
public function __construct(\App\Storage\User $storage)
{
if (!$this->_username && isset($_GET["u"])) {
$this->setUsername($_GET["u"]);
}
if (!$this->_password && isset($_GET["key"])) {
$this->setPassword($_GET["key"]);
}
parent::__construct($storage);
}
public function authenticate()
{
if (!$this->_username || !$this->_password) {
return null;
}
$user = $this->_storage->fetchByUsername($this->_username);
if ($user && $user->getApiKey() == $this->_password) {
return $user;
}
return null;
}
}