Laravel's "logout other devices" feature not working

Viewed 2532

I'm using Laravel 6.0.4. I was asked to logout users from all devices whenever they log in from a new location. Supposedly, Laravel makes this very easy with this: https://laracasts.com/series/whats-new-in-laravel-5-6/episodes/7

public function logoutOtherDevices($password, $attribute = 'password'){ ... }

I can see that the code changes the password hash in the database, but the user is still logged in. So it must be that somewhere in the code I am failing to check that the hash has changed. I'm not an expert, perhaps this is an issue related to guards? Our system has four guards. Could it be that some of the guards are not being authenticated correctly? That the guard is not using the hash from the database but some other system?

So, how do I figure out why Laravel isn't logging people out from other devices? I will share config data if you want, just ask me which data to post


Auth.php

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'staff' => [
            'driver' => 'session',
            'provider' => 'staff'
        ],
       'partner' => [
           'driver' => 'session',
           'provider' => 'partner'
       ],
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],
    ],

    'providers' => [
       'partner' => [
           'driver' => 'eloquent',
           'model' => \App\Models\Partner::class,
       ],
        'staff' => [
            'driver' => 'eloquent',
            'model' => \App\Models\Staff::class
        ],
        'users' => [
            'driver' => 'database',
            'table' => 'users',
        ],
    ],

    'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
        'partner' => [
            'provider' => 'partner',
            'table' => 'password_resets',
            'expire' => 60,
        ],
        'staff' => [
            'provider' => 'staff',
            'table' => 'password_resets',
            'expire' => 60,
        ]
    ],

session.php

    'driver' => env('SESSION_DRIVER', 'file'),
    'lifetime' => env('SESSION_LIFETIME', 120),
    'expire_on_close' => false,
    'encrypt' => false,
    'files' => storage_path('framework/sessions'),
    'connection' => env('SESSION_CONNECTION', null),
    'table' => 'sessions',
    'store' => env('SESSION_STORE', null),
    'lottery' => [2, 100],
    'cookie' => env(
        'SESSION_COOKIE',
        Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
    ),
    'path' => '/',
    'domain' => env('SESSION_DOMAIN', null),
    'secure' => env('SESSION_SECURE_COOKIE', false),
    'http_only' => true,
    'same_site' => null,
0 Answers
Related