Skip to content
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

How clear all cache and session on impersonate logout. #65

Open
paulocastellano opened this issue Dec 13, 2019 · 3 comments
Open

How clear all cache and session on impersonate logout. #65

paulocastellano opened this issue Dec 13, 2019 · 3 comments

Comments

@paulocastellano
Copy link

Hello,

My project is based on cache and session, i need clear on impersonate logout.

Exemple of logout in my project:

public function logout(Request $request)
    {
        session()->flush();

        Cache::pull('user-id-' .  Session()->get('user.id'));

        Auth::logout();

        return redirect(route('home'));
    }

It's possible?

@KABBOUCHI
Copy link
Owner

session()->flush() it will clear everything.

you can also listen for LeaveImpersonation::class or TakeImpersonation::class and take actions.

use Lab404\Impersonate\Events\LeaveImpersonation;

Event::listen(LeaveImpersonation::class, function ($impersonator, $impersonated) {
        //
});
use Lab404\Impersonate\Events\TakeImpersonation;

Event::listen(TakeImpersonation::class, function ($impersonator, $impersonated) {
        //
});

@paulocastellano
Copy link
Author

session()->flush() it will clear everything.

you can also listen for LeaveImpersonation::class or TakeImpersonation::class and take actions.

use Lab404\Impersonate\Events\LeaveImpersonation;

Event::listen(LeaveImpersonation::class, function ($impersonator, $impersonated) {
        //
});
use Lab404\Impersonate\Events\TakeImpersonation;

Event::listen(TakeImpersonation::class, function ($impersonator, $impersonated) {
        //
});

Thanks for help @KABBOUCHI Kabbouchi, i need listen in EventServiceProvider (boot) ?

@KABBOUCHI
Copy link
Owner

yes in the EventServiceProvider, https://laravel.com/docs/5.7/events#manually-registering-events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants