1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-04 10:24:07 +02:00

upload framework

This commit is contained in:
Robin Appelman 2017-03-20 21:51:03 +01:00
commit a1a9504f11
30 changed files with 1578 additions and 155 deletions

View file

@ -1,38 +0,0 @@
<?php namespace Providers;
use Doctrine\DBAL\Connection;
use RandomLib\Generator;
class AuthProvider extends BaseProvider {
/**
* @var Generator
*/
private $generator;
public function __construct(Connection $db, Generator $generator) {
parent::__construct($db);
$this->generator = $generator;
}
public function generateToken() {
return $this->generator->generateString(32, Generator::CHAR_ALNUM);
}
public function setUser($token, \SteamId $steamid, $key) {
apc_store($token, [
'name' => $steamid->getNickname(),
'steamid' => $steamid->getSteamId64(),
'key' => $key
]);
}
public function getUser($token) {
$found = true;
$result = apc_fetch($token, $found);
return ($found) ? $result : ['name' => null, 'steamid' => null, 'key' => null];
}
public function logout($token) {
apc_delete($token);
}
}