Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
8f68ad1a
Commit
8f68ad1a
authored
Nov 03, 2020
by
Davide Aprea
Browse files
added key validation middleware
parent
1b086e68
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Kernel.php
View file @
8f68ad1a
...
...
@@ -63,5 +63,6 @@ class Kernel extends HttpKernel
'humanverification'
=>
\
App\Http\Middleware\HumanVerification
::
class
,
'useragentmaster'
=>
\
App\Http\Middleware\UserAgentMaster
::
class
,
'browserverification'
=>
\
App\Http\Middleware\BrowserVerification
::
class
,
'keyvalidation'
=>
\
App\Http\Middleware\KeyValidation
::
class
,
];
}
app/Http/Middleware/KeyValidation.php
0 → 100644
View file @
8f68ad1a
<?php
namespace
App\Http\Middleware
;
use
Closure
;
use
Cookie
;
use
App\Models\Key
;
class
KeyValidation
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public
function
handle
(
$request
,
Closure
$next
)
{
if
(
isset
(
$request
->
key
)){
$pKey
=
new
Key
(
$request
->
key
);
}
if
(
Cookie
::
get
(
'key'
)){
$cKey
=
new
Key
(
$request
->
key
);
}
if
(
$pKey
->
getStatus
()
||
$cKey
->
getStatus
())
return
$next
(
$request
);
}
}
app/Models/Key.php
View file @
8f68ad1a
...
...
@@ -15,7 +15,7 @@ class Key{
# always returns true or false
public
function
getStatus
()
{
if
(
$this
->
status
===
null
)
{
updateStatus
();
$this
->
updateStatus
();
}
if
(
$this
->
status
===
null
||
$this
->
status
===
false
)
{
return
false
;
...
...
@@ -60,7 +60,7 @@ class Key{
if
(
$result
->
{
'api-access'
}
==
true
)
{
return
true
;
}
else
{
$this
->
status
=
false
;
$this
->
status
=
false
;
return
false
;
}
}
catch
(
\
ErrorException
$e
)
{
...
...
routes/web.php
View file @
8f68ad1a
...
...
@@ -197,7 +197,7 @@ Route::group(
return
redirect
(
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
'/'
));
});
Route
::
match
([
'get'
,
'post'
],
'meta/meta.ger3'
,
'MetaGerSearch@search'
)
->
middleware
(
'browserverification'
,
'humanverification'
,
'useragentmaster'
)
->
name
(
"resultpage"
);
Route
::
match
([
'get'
,
'post'
],
'meta/meta.ger3'
,
'MetaGerSearch@search'
)
->
middleware
(
'keyvalidation'
,
'browserverification'
,
'humanverification'
,
'useragentmaster'
)
->
name
(
"resultpage"
);
Route
::
get
(
'meta/loadMore'
,
'MetaGerSearch@loadMore'
);
Route
::
post
(
'img/cat.jpg'
,
'HumanVerification@remove'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment