mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-04 02:14:06 +02:00
Add php-cs-fixer
This commit is contained in:
parent
e00e6ece5f
commit
309ae17036
54 changed files with 4900 additions and 4106 deletions
|
|
@ -6,69 +6,69 @@ use Demostf\API\Providers\UserProvider;
|
|||
use flight\Engine;
|
||||
|
||||
class AuthController extends BaseController {
|
||||
/**
|
||||
* @var UserProvider
|
||||
*/
|
||||
private $userProvider;
|
||||
/**
|
||||
* @var UserProvider
|
||||
*/
|
||||
private $userProvider;
|
||||
|
||||
/**
|
||||
* @var AuthProvider
|
||||
*/
|
||||
private $authProvider;
|
||||
/**
|
||||
* @var AuthProvider
|
||||
*/
|
||||
private $authProvider;
|
||||
|
||||
/** @var string */
|
||||
private $host;
|
||||
/** @var string */
|
||||
private $host;
|
||||
|
||||
private $apiRoot;
|
||||
private $apiRoot;
|
||||
|
||||
public function __construct(UserProvider $userProvider, AuthProvider $authProvider, string $host, string $apiRoot) {
|
||||
$this->userProvider = $userProvider;
|
||||
$this->authProvider = $authProvider;
|
||||
$this->host = $host;
|
||||
$this->apiRoot = $apiRoot;
|
||||
}
|
||||
public function __construct(UserProvider $userProvider, AuthProvider $authProvider, string $host, string $apiRoot) {
|
||||
$this->userProvider = $userProvider;
|
||||
$this->authProvider = $authProvider;
|
||||
$this->host = $host;
|
||||
$this->apiRoot = $apiRoot;
|
||||
}
|
||||
|
||||
public function token() {
|
||||
echo $this->authProvider->generateToken();
|
||||
}
|
||||
public function token() {
|
||||
echo $this->authProvider->generateToken();
|
||||
}
|
||||
|
||||
public function get($token) {
|
||||
$userData = $this->authProvider->getUser($token);
|
||||
\Flight::json([
|
||||
'token' => $token,
|
||||
'steamid' => $userData['steamid'],
|
||||
'name' => $userData['name'],
|
||||
'key' => $userData['key']
|
||||
]);
|
||||
}
|
||||
public function get($token) {
|
||||
$userData = $this->authProvider->getUser($token);
|
||||
\Flight::json([
|
||||
'token' => $token,
|
||||
'steamid' => $userData['steamid'],
|
||||
'name' => $userData['name'],
|
||||
'key' => $userData['key']
|
||||
]);
|
||||
}
|
||||
|
||||
public function login($token) {
|
||||
$_SESSION['return'] = $this->query('return', 'https://' . $this->host);
|
||||
$steam = new SteamLogin();
|
||||
$url = $steam->url($this->apiRoot . '/auth/handle/' . urlencode($token), $this->apiRoot);
|
||||
\Flight::redirect(str_replace('&', '&', $url)); // headers make no sense
|
||||
}
|
||||
public function login($token) {
|
||||
$_SESSION['return'] = $this->query('return', 'https://' . $this->host);
|
||||
$steam = new SteamLogin();
|
||||
$url = $steam->url($this->apiRoot . '/auth/handle/' . urlencode($token), $this->apiRoot);
|
||||
\Flight::redirect(str_replace('&', '&', $url)); // headers make no sense
|
||||
}
|
||||
|
||||
public function logout($token) {
|
||||
$this->authProvider->logout($token);
|
||||
\Flight::json([
|
||||
'token' => $token,
|
||||
'steamid' => null,
|
||||
'name' => null,
|
||||
'key' => null
|
||||
]);
|
||||
}
|
||||
public function logout($token) {
|
||||
$this->authProvider->logout($token);
|
||||
\Flight::json([
|
||||
'token' => $token,
|
||||
'steamid' => null,
|
||||
'name' => null,
|
||||
'key' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function handle($token) {
|
||||
$return = $_SESSION['return'] ?? 'https://' . $this->host;
|
||||
unset($_SESSION['return']);
|
||||
$steam = new SteamLogin();
|
||||
$steamId = $steam->validate();
|
||||
if ($steamId) {
|
||||
$steamIdObject = new \SteamId($steamId);
|
||||
$key = $this->userProvider->store($steamIdObject);
|
||||
$this->authProvider->setUser($token, $steamIdObject, $key);
|
||||
}
|
||||
\Flight::redirect($return);
|
||||
}
|
||||
public function handle($token) {
|
||||
$return = $_SESSION['return'] ?? 'https://' . $this->host;
|
||||
unset($_SESSION['return']);
|
||||
$steam = new SteamLogin();
|
||||
$steamId = $steam->validate();
|
||||
if ($steamId) {
|
||||
$steamIdObject = new \SteamId($steamId);
|
||||
$key = $this->userProvider->store($steamIdObject);
|
||||
$this->authProvider->setUser($token, $steamIdObject, $key);
|
||||
}
|
||||
\Flight::redirect($return);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue