mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-12-06 05:51:57 +01:00
Upgrade LBCAlerte to version 3.3
Add upgrade script
This commit is contained in:
31
sources/lib/Auth/ApiKey.php
Normal file
31
sources/lib/Auth/ApiKey.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user