-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
closes #5 #11
base: main
Are you sure you want to change the base?
closes #5 #11
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,8 @@ | |
'prefix' => config('cookieconsent.url.prefix'), | ||
], function() { | ||
Route::get('script', ScriptController::class) | ||
->name('script'); | ||
->name('script') | ||
->middleware('cache.headers:public;max_age=2628000;etag'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please explain why this line is necessary and how it is related to the issue you're solving? Thanks! |
||
|
||
Route::post('accept-all', AcceptAllController::class) | ||
->name('accept.all'); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,21 +2,35 @@ | |||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
namespace Whitecube\LaravelCookieConsent\Http\Controllers; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
use Whitecube\LaravelCookieConsent\CookiesManager; | ||||||||||||||||||||||||||||||||
use Illuminate\Support\Facades\Cookie; | ||||||||||||||||||||||||||||||||
use Illuminate\Http\Request; | ||||||||||||||||||||||||||||||||
use Whitecube\LaravelCookieConsent\CookiesManager; | ||||||||||||||||||||||||||||||||
use Whitecube\LaravelCookieConsent\Facades\Cookies; | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not need the |
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
class ResetController | ||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||
public function __invoke(Request $request, CookiesManager $cookies) | ||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||
$response = ! $request->expectsJson() | ||||||||||||||||||||||||||||||||
class ResetController { | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
public function __invoke(Request $request, CookiesManager $cookies) { | ||||||||||||||||||||||||||||||||
$response = !$request->expectsJson() | ||||||||||||||||||||||||||||||||
Comment on lines
+11
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not use your own coding style rules within the package (I guess you're using an automatic CS fixer with different rules than ours). Thanks ! |
||||||||||||||||||||||||||||||||
? redirect()->back() | ||||||||||||||||||||||||||||||||
: response()->json([ | ||||||||||||||||||||||||||||||||
'status' => 'ok', | ||||||||||||||||||||||||||||||||
'scripts' => $cookies->getNoticeScripts(true), | ||||||||||||||||||||||||||||||||
'notice' => $cookies->getNoticeMarkup(), | ||||||||||||||||||||||||||||||||
]); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
$domain = config('cookieconsent.cookie.domain'); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since we're using |
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
// delete all defined cookies | ||||||||||||||||||||||||||||||||
foreach (Cookies::getCategories() as $category) { | ||||||||||||||||||||||||||||||||
foreach ($category->getCookies() as $cookie) { | ||||||||||||||||||||||||||||||||
Cookie::queue(Cookie::forget( | ||||||||||||||||||||||||||||||||
name: $cookie->name, | ||||||||||||||||||||||||||||||||
domain: $domain, | ||||||||||||||||||||||||||||||||
)); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+24
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Did not test, but this way we do not need to use Cookie queuing and the |
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
return $response->withoutCookie( | ||||||||||||||||||||||||||||||||
cookie: config('cookieconsent.cookie.name'), | ||||||||||||||||||||||||||||||||
domain: config('cookieconsent.cookie.domain'), | ||||||||||||||||||||||||||||||||
Comment on lines
35
to
36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the suggested code for removing cookies works, this is not needed anymore.