Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
263
Merge Requests
32
CI / CD
Security & Compliance
Packages
Analytics
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Compare Revisions
05a6900146c752791a9b6bafb20b24b38c4bc949...c20db6f909810dc466c4f2b8a0b5364353b3db5e
Source
c20db6f909810dc466c4f2b8a0b5364353b3db5e
...
Target
05a6900146c752791a9b6bafb20b24b38c4bc949
Compare
Commits (3)
(fix): lint
· 0647a258
Marcelo Rivera
authored
1 hour ago
0647a258
(fix): error response from prepsr7/router
· 68282597
Marcelo Rivera
authored
36 minutes ago
68282597
(feat): handle UnverifiedEmailException in PSR7 routing
· c20db6f9
Marcelo Rivera
authored
36 minutes ago
c20db6f9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
24 deletions
+34
-24
Core/Blogs/Manager.php
View file @
c20db6f9
...
...
@@ -59,8 +59,7 @@ class Manager
$search
=
null
,
PropagateProperties
$propagateProperties
=
null
,
ACL
$acl
=
null
)
{
)
{
$this
->
repository
=
$repository
?:
new
Repository
();
$this
->
paywallReview
=
$paywallReview
?:
new
Delegates\PaywallReview
();
$this
->
slug
=
$slug
?:
new
Delegates\Slug
();
...
...
This diff is collapsed.
Core/Router/Exceptions/UnverifiedEmailException.php
View file @
c20db6f9
...
...
@@ -7,8 +7,8 @@ namespace Minds\Core\Router\Exceptions;
class
UnverifiedEmailException
extends
\Exception
{
public
function
__construct
()
{
public
function
__construct
()
{
$this
->
message
=
'You must verify your account'
;
}
}
This diff is collapsed.
Core/Router/Middleware/Kernel/RegistryEntryMiddleware.php
View file @
c20db6f9
...
...
@@ -9,11 +9,13 @@ namespace Minds\Core\Router\Middleware\Kernel;
use
Exception
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Di\Ref
as
DiRef
;
use
Minds\Core\Router\Exceptions\UnverifiedEmailException
;
use
Minds\Core\Router\RegistryEntry
;
use
Psr\Http\Message\ResponseInterface
;
use
Psr\Http\Message\ServerRequestInterface
;
use
Psr\Http\Server\MiddlewareInterface
;
use
Psr\Http\Server\RequestHandlerInterface
;
use
Zend\Diactoros\Response\JsonResponse
;
class
RegistryEntryMiddleware
implements
MiddlewareInterface
{
...
...
@@ -50,23 +52,32 @@ class RegistryEntryMiddleware implements MiddlewareInterface
$binding
=
$registryEntry
->
getBinding
();
$parameters
=
$registryEntry
->
extract
(
$request
->
getUri
()
->
getPath
());
if
(
$binding
instanceof
DiRef
)
{
return
call_user_func
(
[
Di
::
_
()
->
get
(
$binding
->
getProvider
()),
$binding
->
getMethod
()
],
$request
->
withAttribute
(
'parameters'
,
$parameters
)
);
}
elseif
(
is_callable
(
$binding
))
{
return
call_user_func
(
$binding
,
$request
->
withAttribute
(
'parameters'
,
$parameters
)
);
}
else
{
throw
new
Exception
(
"Invalid router binding"
);
try
{
if
(
$binding
instanceof
DiRef
)
{
return
call_user_func
(
[
Di
::
_
()
->
get
(
$binding
->
getProvider
()),
$binding
->
getMethod
(),
],
$request
->
withAttribute
(
'parameters'
,
$parameters
)
);
}
elseif
(
is_callable
(
$binding
))
{
return
call_user_func
(
$binding
,
$request
->
withAttribute
(
'parameters'
,
$parameters
)
);
}
else
{
throw
new
Exception
(
"Invalid router binding"
);
}
}
catch
(
UnverifiedEmailException
$e
)
{
return
new
JsonResponse
([
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
(),
'code'
=>
403
,
'must_verify'
=>
true
,
],
403
);
}
}
...
...
This diff is collapsed.
Core/Router/PrePsr7/Router.php
View file @
c20db6f9
...
...
@@ -162,7 +162,8 @@ class Router
header
(
'HTTP/1.1 403 Forbidden'
,
true
,
403
);
echo
json_encode
([
'error'
=>
$e
->
getMessage
(),
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
(),
'code'
=>
403
,
'must_verify'
=>
true
]);
...
...
This diff is collapsed.
Spec/Core/Blogs/ManagerSpec.php
View file @
c20db6f9
...
...
@@ -48,8 +48,7 @@ class ManagerSpec extends ObjectBehavior
Delegates\Search
$search
,
PropagateProperties
$propagateProperties
,
ACL
$acl
)
{
)
{
$this
->
beConstructedWith
(
$repository
,
$paywallReview
,
...
...
This diff is collapsed.