-1

I have a system where Admin will Enter his Client Dashboard with Client's Credentials. Admin has all information of Clients.

---------------------
Client1         Login
Client2         Login
---------------------

Now in my Controller I want to do this action. Admin will go to his Client Dashboard. Is it possible to do?

public function login(User $user)       
{
  $credentials = $user->only('email', 'password');
  Auth::logout();
  // But after logout() it will stop, I know that. 

  if (Auth::attempt($credentials)) {
  // Authentication passed...
  return redirect('/');
  }
}

Is it possible to Login in two accounts (Admin & Client) at the same time? :-P

Mr. Perfectionist
  • 2,219
  • 1
  • 19
  • 30
  • Sounds like you are describing impersonation: https://github.com/404labfr/laravel-impersonate – Angad Dubey Jan 01 '20 at 09:14
  • You can have two authentication guards e.g admin and default and sign in as a different user in either. The main question is why do you want to do this? It feels like an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). – apokryfos Jan 01 '20 at 09:43
  • @apokryfos, actually my client want this system. He is admin. He want to see his customer's all activities.... – Mr. Perfectionist Jan 01 '20 at 09:46
  • I have two guards. Admin and Client. He don't want to memorise the Client Credentials. – Mr. Perfectionist Jan 01 '20 at 09:48
  • He doesn't need to login as someone to see their activity. You can just have admins to be authorized to see everyones activity. Using two guards could work but if they're both backed by the session they would conflict. – apokryfos Jan 01 '20 at 10:19
  • I did that. But he want to check one by one. :-( – Mr. Perfectionist Jan 01 '20 at 10:28

1 Answers1

0

for two login in same time in laravel u have to create admin table or client table and make seprate login in admin guard and default login u have to overwrite login with user guard then only u can maintain 2 login in same time in laravel

GUARD doc link here

Kamlesh Paul
  • 8,132
  • 1
  • 12
  • 26