Authenticate in another PHP/Laravel application

Asked

Viewed 137 times

3

I am logged in this application PHP , in this application has a list of users as the image below: inserir a descrição da imagem aqui

By clicking this button Log in I want to be redirected to a Dashboard that is in the same domain, but uses Laravel and requires authentication according to the image below:

inserir a descrição da imagem aqui

I have the authentication data to access this Dashboard, but I wanted it to be done automatically by clicking the button Log in, could do this using PHP?

  • You have already asked this in this question: https://answall.com/q/315905/5878. Why create another? It was not easier to edit the original?

  • Delete this old question.

1 answer

1


You can use the function login of Auth, you pass the model User as a parameter, in this way:

public function logar_com($id)
{
        Auth::login(User::findOrFail($id));
        return redirect()
            ->action('HomeController@index');

}

Instead of getting the User id can use where and search by email.

  • A good one too, it would be nice if users had a token, and you received it in this login method, to by token, validate the user and return to the index page with it authenticated. The token helps in the security issue, would be nice

Browser other questions tagged

You are not signed in. Login or sign up in order to post.