Compare commits
No commits in common. "13796e58c7e852e7cdb9ebe4798c27ef385d31cd" and "45a22c2dd44532c42d99ad08926987aca78c3606" have entirely different histories.
13796e58c7
...
45a22c2dd4
@ -10,7 +10,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"esoko/soko-web": "0.3",
|
||||
"esoko/soko-web": "0.2.1",
|
||||
"firebase/php-jwt": "^6.4"
|
||||
},
|
||||
"require-dev": {
|
||||
|
8
composer.lock
generated
8
composer.lock
generated
@ -4,15 +4,15 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "64c21f0e5181bd39d8977af72e2aeddc",
|
||||
"content-hash": "695034ad53031c4fdacbc6f551d610e3",
|
||||
"packages": [
|
||||
{
|
||||
"name": "esoko/soko-web",
|
||||
"version": "v0.3",
|
||||
"version": "v0.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.esoko.eu/esoko/soko-web.git",
|
||||
"reference": "014a5480967c03c00dda5ee34c7eaf4be224b96e"
|
||||
"reference": "4af7ae352108e7ba151fca2633ff4b40b3194b32"
|
||||
},
|
||||
"require": {
|
||||
"phpmailer/phpmailer": "^6.8",
|
||||
@ -33,7 +33,7 @@
|
||||
"GNU GPL 3.0"
|
||||
],
|
||||
"description": "Lightweight web framework",
|
||||
"time": "2023-04-16T14:54:22+00:00"
|
||||
"time": "2023-04-16T14:00:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "firebase/php-jwt",
|
||||
|
@ -22,11 +22,13 @@ if ($match !== null) {
|
||||
$handler = $route->getHandler();
|
||||
$controller = new $handler[0](Container::$request);
|
||||
|
||||
if (
|
||||
$controller instanceof SokoWeb\Interfaces\Authentication\IAuthenticationRequired &&
|
||||
$controller->isAuthenticationRequired() &&
|
||||
Container::$request->user() === null
|
||||
) {
|
||||
if ($controller instanceof SokoWeb\Interfaces\Authorization\ISecured) {
|
||||
$authorized = $controller->authorize();
|
||||
} else {
|
||||
$authorized = true;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
Container::$request->session()->set('redirect_after_login', substr($_SERVER['REQUEST_URI'], strlen('/')));
|
||||
$response = new Redirect(Container::$routeCollection->getRoute('login')->generateLink(), IRedirect::TEMPORARY);
|
||||
header('Location: ' . $response->getUrl(), true, $response->getHttpCode());
|
||||
@ -40,19 +42,14 @@ if ($match !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!($controller instanceof SokoWeb\Interfaces\Authorization\ISecured) ||
|
||||
$controller->authorize()
|
||||
) {
|
||||
$response = call_user_func([$controller, $handler[1]]);
|
||||
if ($response instanceof SokoWeb\Interfaces\Response\IContent) {
|
||||
header('Content-Type: ' . $response->getContentType() . '; charset=UTF-8');
|
||||
$response->render();
|
||||
return;
|
||||
} elseif ($response instanceof SokoWeb\Interfaces\Response\IRedirect) {
|
||||
header('Location: ' . $response->getUrl(), true, $response->getHttpCode());
|
||||
return;
|
||||
}
|
||||
$response = call_user_func([$controller, $handler[1]]);
|
||||
if ($response instanceof SokoWeb\Interfaces\Response\IContent) {
|
||||
header('Content-Type: ' . $response->getContentType() . '; charset=UTF-8');
|
||||
$response->render();
|
||||
return;
|
||||
} elseif ($response instanceof SokoWeb\Interfaces\Response\IRedirect) {
|
||||
header('Location: ' . $response->getUrl(), true, $response->getHttpCode());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,14 @@ use RVR\PersistentData\Model\User;
|
||||
use RVR\Repository\CommunityRepository;
|
||||
use RVR\Repository\CommunityMemberRepository;
|
||||
use RVR\Repository\UserRepository;
|
||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||
use SokoWeb\Interfaces\Request\IRequest;
|
||||
use SokoWeb\Interfaces\Response\IContent;
|
||||
use SokoWeb\PersistentData\PersistentDataManager;
|
||||
use SokoWeb\Response\HtmlContent;
|
||||
use SokoWeb\Response\JsonContent;
|
||||
|
||||
class CommunityController implements IAuthenticationRequired
|
||||
class CommunityController implements ISecured
|
||||
{
|
||||
private IRequest $request;
|
||||
|
||||
@ -35,9 +35,9 @@ class CommunityController implements IAuthenticationRequired
|
||||
$this->communityMemberRepository = new CommunityMemberRepository();
|
||||
}
|
||||
|
||||
public function isAuthenticationRequired(): bool
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->request->user() !== null;
|
||||
}
|
||||
|
||||
public function getCommunityHome(): ?IContent
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
use RVR\PersistentData\Model\User;
|
||||
use RVR\Repository\CommunityMemberRepository;
|
||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||
use SokoWeb\Interfaces\Request\IRequest;
|
||||
use SokoWeb\Interfaces\Response\IContent;
|
||||
use SokoWeb\Response\HtmlContent;
|
||||
|
||||
class HomeController implements IAuthenticationRequired
|
||||
class HomeController implements ISecured
|
||||
{
|
||||
private IRequest $request;
|
||||
|
||||
@ -19,9 +19,9 @@ class HomeController implements IAuthenticationRequired
|
||||
$this->communityMemberRepository = new CommunityMemberRepository();
|
||||
}
|
||||
|
||||
public function isAuthenticationRequired(): bool
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->request->user() !== null;
|
||||
}
|
||||
|
||||
public function getHome(): IContent
|
||||
|
@ -4,14 +4,14 @@ use DateTime;
|
||||
use RVR\PersistentData\Model\OAuthToken;
|
||||
use RVR\PersistentData\Model\User;
|
||||
use RVR\Repository\OAuthClientRepository;
|
||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||
use SokoWeb\Interfaces\Request\IRequest;
|
||||
use SokoWeb\Interfaces\Response\IRedirect;
|
||||
use SokoWeb\Response\Redirect;
|
||||
use SokoWeb\PersistentData\PersistentDataManager;
|
||||
use SokoWeb\Response\HtmlContent;
|
||||
|
||||
class OAuthAuthController implements IAuthenticationRequired
|
||||
class OAuthAuthController implements ISecured
|
||||
{
|
||||
private IRequest $request;
|
||||
|
||||
@ -26,9 +26,9 @@ class OAuthAuthController implements IAuthenticationRequired
|
||||
$this->oAuthClientRepository = new OAuthClientRepository();
|
||||
}
|
||||
|
||||
public function isAuthenticationRequired(): bool
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->request->user() !== null;
|
||||
}
|
||||
|
||||
public function auth()
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use DateTime;
|
||||
use SokoWeb\Http\Request;
|
||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||
use SokoWeb\Interfaces\Request\IRequest;
|
||||
use SokoWeb\Interfaces\Response\IContent;
|
||||
use SokoWeb\Interfaces\Response\IRedirect;
|
||||
@ -15,7 +15,7 @@ use SokoWeb\Response\Redirect;
|
||||
use SokoWeb\Util\JwtParser;
|
||||
use RVR\Repository\UserRepository;
|
||||
|
||||
class UserController implements IAuthenticationRequired
|
||||
class UserController implements ISecured
|
||||
{
|
||||
private IRequest $request;
|
||||
|
||||
@ -30,9 +30,9 @@ class UserController implements IAuthenticationRequired
|
||||
$this->userRepository = new UserRepository();
|
||||
}
|
||||
|
||||
public function isAuthenticationRequired(): bool
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->request->user() !== null;
|
||||
}
|
||||
|
||||
public function getAccount(): IContent
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php namespace RVR\Controller;
|
||||
|
||||
use RVR\Repository\UserRepository;
|
||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||
use SokoWeb\Interfaces\Request\IRequest;
|
||||
use SokoWeb\Interfaces\Response\IContent;
|
||||
use SokoWeb\Response\JsonContent;
|
||||
|
||||
class UserSearchController implements IAuthenticationRequired
|
||||
class UserSearchController implements ISecured
|
||||
{
|
||||
private IRequest $request;
|
||||
|
||||
@ -18,9 +18,9 @@ class UserSearchController implements IAuthenticationRequired
|
||||
$this->userRepository = new UserRepository();
|
||||
}
|
||||
|
||||
public function isAuthenticationRequired(): bool
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->request->user() !== null;
|
||||
}
|
||||
|
||||
public function searchUser(): IContent
|
||||
|
Loading…
Reference in New Issue
Block a user