I
I
Ivan2022-03-19 11:15:26
Laravel
Ivan, 2022-03-19 11:15:26

Laravel how to enable authorization on only one device?

I want to make it so that if a person logs in under any PC, in any browser. He was no longer able to log in elsewhere. Those. he needs to log out of the account and only then he will be able to log in on another device (or in another browser).

How can this be implemented? How to check.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dsmoke, 2022-03-20
@dsmoke

Auth::logoutOtherDevices('password');
https://laravel.com/api/9.x/Illuminate/Support/Fac...

V
Vladimir Kokhan, 2022-03-19
@SkazochNick

Before logging in
auth()->logout();

L
lil_koi, 2022-03-19
@lil_koi

You can make one more "in_auth" column in the users table. And when authorizing, set true, if the user wants to re-authorize, then check this parameter. If it's true, then either log out the previous one, or don't let it log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question