Skip to content

Commit

Permalink
Switched to session storage
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianPrieber committed Jul 14, 2023
1 parent 2a47554 commit b99a975
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ public function authAs(request $request)
$user->remember_token = null;
$user->save();

setcookie("display_auth_nav", "", time() - 3600, "/");
$request->session()->forget('display_auth_nav');

Auth::loginUsingId($userID);

Expand Down
9 changes: 5 additions & 4 deletions app/Http/Middleware/Impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ public function handle($request, Closure $next)
}

Auth::loginUsingId($id);
setcookie("display_auth_nav", "true", time() + (10 * 365 * 24 * 60 * 60), "/");
$request->session()->put('display_auth_nav', true);
$request->session()->save();
}

if(isset($_COOKIE['display_auth_nav'])) {
if($request->session()->has('display_auth_nav')) {
if (file_exists(base_path(findAvatar($id)))) {
$img = '<img alt="avatar" class="iimg irounded" src="' . url(findAvatar($id)) . '">';
} elseif (file_exists(base_path("assets/linkstack/images/").findFile('avatar'))) {
Expand Down Expand Up @@ -148,8 +149,8 @@ function submitForm() {

return $response;
} else {
if(isset($_COOKIE['display_auth_nav'])) {
setcookie("display_auth_nav", "", time() - 3600, "/");
if($request->session()->has('display_auth_nav')) {
$request->session()->forget('display_auth_nav');
Auth::logout();
}
return $next($request);
Expand Down

0 comments on commit b99a975

Please sign in to comment.