Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
7b510145
Commit
7b510145
authored
4 years ago
by
Davide Aprea
Browse files
Options
Downloads
Patches
Plain Diff
fixed provider and middleware
parent
e598ed08
No related branches found
No related tags found
3 merge requests
!1895
Development
,
!1747
Development
,
!1731
Resolve "removing integration of obsolete resultpage formats"
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/Http/Middleware/KeyValidation.php
+20
-7
20 additions, 7 deletions
app/Http/Middleware/KeyValidation.php
app/Providers/KeyServiceProvider.php
+4
-3
4 additions, 3 deletions
app/Providers/KeyServiceProvider.php
with
24 additions
and
10 deletions
app/Http/Middleware/KeyValidation.php
+
20
−
7
View file @
7b510145
...
...
@@ -6,8 +6,16 @@ use Closure;
use
Cookie
;
use
App\Models\Key
;
//use KeyServiceProvider;
class
KeyValidation
{
protected
$key
;
public
function
__construct
(
Key
$key
){
$this
->
key
=
$key
;
}
/**
* Handle an incoming request.
*
...
...
@@ -15,19 +23,24 @@ class KeyValidation
* @param \Closure $next
* @return mixed
*/
public
function
handle
(
$request
,
Closure
$next
,
Key
$key
)
public
function
handle
(
$request
,
Closure
$next
)
{
if
(
isset
(
$key
)
&&
$key
->
getStatus
())
{
return
$next
(
$request
);
}
elseif
(
isset
(
$key
)
&&
!
$key
->
getStatus
())
{
//dd($this->key->key, $this->key->getStatus());
if
(
$this
->
key
->
key
!==
''
&&
$this
->
key
->
getStatus
())
{
return
response
(
'valid key'
);
//return $next($request);
}
elseif
(
$this
->
key
->
key
!==
''
&&
!
$this
->
key
->
getStatus
())
{
if
(
$request
->
filled
(
'key'
)){
return
redirect
(
$request
->
except
(
'key'
));
return
response
(
'invalid key (parameter)'
);
//return redirect($request->except('key'));
}
else
{
Cookie
::
queue
(
'key'
,
''
,
0
,
'/'
,
null
,
false
,
false
);
return
redirect
(
$request
);
return
response
(
'invalid key (cookie)'
);
//return redirect($request);
}
}
else
{
return
redirect
(
$request
);
return
response
(
'no key'
);
//return redirect($request);
}
}
}
This diff is collapsed.
Click to expand it.
app/Providers/KeyServiceProvider.php
+
4
−
3
View file @
7b510145
...
...
@@ -5,6 +5,7 @@ namespace App\Providers;
use
Illuminate\Support\ServiceProvider
;
use
Request
;
use
Cookie
;
use
App\Models\Key
;
class
KeyServiceProvider
extends
ServiceProvider
{
...
...
@@ -16,11 +17,11 @@ class KeyServiceProvider extends ServiceProvider
public
function
register
()
{
$key
=
""
;
if
(
Cookie
::
get
(
'key'
))
{
if
(
Cookie
::
has
(
'key'
))
{
$key
=
Cookie
::
get
(
'key'
);
}
if
(
isset
(
$request
->
key
))
{
$key
=
$r
equest
->
key
;
if
(
Request
::
filled
(
'
key
'
))
{
$key
=
R
equest
::
input
(
'
key
'
)
;
}
$this
->
app
->
singleton
(
Key
::
class
,
function
(
$app
)
use
(
$key
)
{
return
new
Key
(
$key
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment