Answer the question
In order to leave comments, you need to log in
How to rewrite authentication in Laravel?
I need such authentication - there is a table with fields network, id_in_network. I need to add a method for the Laravel authentication module that takes $network, $idInNetwork and looks for a match in the table. If there is one - it logs in the user, does not find it - creates a record and also logs in. How to implement this beautifully? Without crutches, etc. ? The vendor folder is not under version control and editing it itself is not recommended. Therefore, how can I add such a method then? Where to create a file for adding this method?
Answer the question
In order to leave comments, you need to log in
Where to create a file for adding this method?
If I correctly understood the task, then you do not need to rewrite the authorization.
There are events in Laravel that you can use before user authorization.
https://laravel.com/docs/5.4/authentication#events
You think you need to listen to the event Illuminate\Auth\Events\Attempting
When you create a Listener for this event, in it, you can check what you need and log in the user.
Or use the event Illuminate\Auth\Events\Login
, because you will log in the user in both cases, and after login you will already make the necessary entries in the database if necessary.
As far as I know, since version 5.3, controllers come in a box, and if you need to change the conditions, then just create an authController with the parameters you need
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question