feature/use-new-features-from-soko-web #58
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||||
use SokoWeb\Interfaces\Request\IRequest;
|
use SokoWeb\Interfaces\Request\IRequest;
|
||||||
use SokoWeb\Response\HtmlContent;
|
use SokoWeb\Response\HtmlContent;
|
||||||
use SokoWeb\Response\JsonContent;
|
use SokoWeb\Response\JsonContent;
|
||||||
@ -21,7 +21,7 @@ use MapGuesser\Repository\PlaceRepository;
|
|||||||
use MapGuesser\Repository\UserInChallengeRepository;
|
use MapGuesser\Repository\UserInChallengeRepository;
|
||||||
use SokoWeb\Response\Redirect;
|
use SokoWeb\Response\Redirect;
|
||||||
|
|
||||||
class GameController implements ISecured
|
class GameController implements IAuthenticationRequired
|
||||||
{
|
{
|
||||||
const NUMBER_OF_ROUNDS = 5;
|
const NUMBER_OF_ROUNDS = 5;
|
||||||
|
|
||||||
@ -53,9 +53,9 @@ class GameController implements ISecured
|
|||||||
$this->userInChallengeRepository = new UserInChallengeRepository();
|
$this->userInChallengeRepository = new UserInChallengeRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authorize(): bool
|
public function isAuthenticationRequired(): bool
|
||||||
{
|
{
|
||||||
return !empty($_ENV['ENABLE_GAME_FOR_GUESTS']) || $this->request->user() !== null;
|
return empty($_ENV['ENABLE_GAME_FOR_GUESTS']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGame(): IContent
|
public function getGame(): IContent
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php namespace MapGuesser\Controller;
|
<?php namespace MapGuesser\Controller;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||||
use SokoWeb\Interfaces\Request\IRequest;
|
use SokoWeb\Interfaces\Request\IRequest;
|
||||||
use MapGuesser\Util\Geo\Position;
|
use MapGuesser\Util\Geo\Position;
|
||||||
use SokoWeb\Response\JsonContent;
|
use SokoWeb\Response\JsonContent;
|
||||||
@ -15,17 +15,14 @@ use MapGuesser\PersistentData\Model\Place;
|
|||||||
use MapGuesser\PersistentData\Model\PlaceInChallenge;
|
use MapGuesser\PersistentData\Model\PlaceInChallenge;
|
||||||
use MapGuesser\PersistentData\Model\User;
|
use MapGuesser\PersistentData\Model\User;
|
||||||
use MapGuesser\PersistentData\Model\UserPlayedPlace;
|
use MapGuesser\PersistentData\Model\UserPlayedPlace;
|
||||||
use MapGuesser\Repository\ChallengeRepository;
|
|
||||||
use MapGuesser\Repository\GuessRepository;
|
use MapGuesser\Repository\GuessRepository;
|
||||||
use MapGuesser\Repository\MapRepository;
|
|
||||||
use MapGuesser\Repository\MultiRoomRepository;
|
use MapGuesser\Repository\MultiRoomRepository;
|
||||||
use MapGuesser\Repository\PlaceInChallengeRepository;
|
use MapGuesser\Repository\PlaceInChallengeRepository;
|
||||||
use MapGuesser\Repository\PlaceRepository;
|
use MapGuesser\Repository\PlaceRepository;
|
||||||
use MapGuesser\Repository\UserInChallengeRepository;
|
use MapGuesser\Repository\UserInChallengeRepository;
|
||||||
use MapGuesser\Repository\UserPlayedPlaceRepository;
|
use MapGuesser\Repository\UserPlayedPlaceRepository;
|
||||||
use MapGuesser\Repository\UserRepository;
|
|
||||||
|
|
||||||
class GameFlowController implements ISecured
|
class GameFlowController implements IAuthenticationRequired
|
||||||
{
|
{
|
||||||
const NUMBER_OF_ROUNDS = 5;
|
const NUMBER_OF_ROUNDS = 5;
|
||||||
const MAX_SCORE = 1000;
|
const MAX_SCORE = 1000;
|
||||||
@ -61,9 +58,9 @@ class GameFlowController implements ISecured
|
|||||||
$this->guessRepository = new GuessRepository();
|
$this->guessRepository = new GuessRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authorize(): bool
|
public function isAuthenticationRequired(): bool
|
||||||
{
|
{
|
||||||
return !empty($_ENV['ENABLE_GAME_FOR_GUESTS']) || $this->request->user() !== null;
|
return empty($_ENV['ENABLE_GAME_FOR_GUESTS']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initialData(): IContent
|
public function initialData(): IContent
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use SokoWeb\Interfaces\Authentication\IUser;
|
use SokoWeb\Interfaces\Authentication\IUser;
|
||||||
|
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||||
use SokoWeb\Interfaces\Request\IRequest;
|
use SokoWeb\Interfaces\Request\IRequest;
|
||||||
use SokoWeb\Interfaces\Response\IContent;
|
use SokoWeb\Interfaces\Response\IContent;
|
||||||
@ -22,7 +23,7 @@ use SokoWeb\Response\JsonContent;
|
|||||||
use MapGuesser\Util\Geo\Bounds;
|
use MapGuesser\Util\Geo\Bounds;
|
||||||
use MapGuesser\Util\Panorama\Pov;
|
use MapGuesser\Util\Panorama\Pov;
|
||||||
|
|
||||||
class MapAdminController implements ISecured
|
class MapAdminController implements IAuthenticationRequired, ISecured
|
||||||
{
|
{
|
||||||
private static string $unnamedMapName = '[unnamed map]';
|
private static string $unnamedMapName = '[unnamed map]';
|
||||||
|
|
||||||
@ -57,11 +58,14 @@ class MapAdminController implements ISecured
|
|||||||
$this->userInChallengeRepository = new UserInChallengeRepository();
|
$this->userInChallengeRepository = new UserInChallengeRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAuthenticationRequired(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
$user = $this->request->user();
|
return $this->request->user()->hasPermission(IUser::PERMISSION_ADMIN);
|
||||||
|
|
||||||
return $user !== null && $user->hasPermission(IUser::PERMISSION_ADMIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMapEditor(): IContent
|
public function getMapEditor(): IContent
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use SokoWeb\Http\Request;
|
use SokoWeb\Http\Request;
|
||||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||||
use SokoWeb\Interfaces\Request\IRequest;
|
use SokoWeb\Interfaces\Request\IRequest;
|
||||||
use SokoWeb\Interfaces\Response\IContent;
|
use SokoWeb\Interfaces\Response\IContent;
|
||||||
use SokoWeb\Interfaces\Response\IRedirect;
|
use SokoWeb\Interfaces\Response\IRedirect;
|
||||||
@ -19,7 +19,7 @@ use SokoWeb\Response\JsonContent;
|
|||||||
use SokoWeb\Response\Redirect;
|
use SokoWeb\Response\Redirect;
|
||||||
use SokoWeb\Util\JwtParser;
|
use SokoWeb\Util\JwtParser;
|
||||||
|
|
||||||
class UserController implements ISecured
|
class UserController implements IAuthenticationRequired
|
||||||
{
|
{
|
||||||
private IRequest $request;
|
private IRequest $request;
|
||||||
|
|
||||||
@ -46,11 +46,9 @@ class UserController implements ISecured
|
|||||||
$this->guessRepository = new GuessRepository();
|
$this->guessRepository = new GuessRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authorize(): bool
|
public function isAuthenticationRequired(): bool
|
||||||
{
|
{
|
||||||
$user = $this->request->user();
|
return true;
|
||||||
|
|
||||||
return $user !== null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAccount(): IContent
|
public function getAccount(): IContent
|
||||||
|
Loading…
Reference in New Issue
Block a user