Laravel 6 Custom Authentication Steps


Step 1) Install Laravel Authentication Package

composer require laravel/ui "^1.0" --dev

php artisan ui vue --auth

Step 2) Make Appropriate Changes to the User Model.

Step 3) Get Rid of Authentication Controller generated by Laravel.

Step 4) Create your own controller 1 for Login and 1 for Adding User

Step 5) You can use custom form requests to separate the Logic from the controller, for instance validation rules etc can be stored in the Form Request.

For E.g

php artisan make:request StoreUserRequest

Now you can pass StoreUserRequest to the Controller. For E.g

public function StoreUser(StoreUserRequest $request)

 

Step 5) Remember to Hash the Password before storing in the DB

  $password = Hash::make($request->password);

Step 6) Use Auth::attempt(['username']=>'WHATEVER OR $request->username','password'=>$request->password)  to Check for Valid User..

Step 7) Auth::User() should return the User anywhere in Views or Controller..




Running Drupal in Docker

I will assume that you have already installed docker. If you haven't installed docker please visit https://www.docker.com/ to download a...