DEV Community

Discussion on: Login Customization in Laravel 8

Collapse
 
aregonyazilim profile image
aregonyazilim

I used the following code;
<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Laravel\Fortify\Fortify;

class LoginController extends Controller
{
public function authenticate(Request $request)
{

    Fortify::authenticateUsing(function (Request $request) {

        $user = User::where('email', $request->email)->first();

        if ($user && Hash::check($request->password, $user->password)) {
            print_r($user);
            return $user;
        }
    });

}

}
But it doesn't work. Where am I going wrong?

Collapse
 
aibnuhibban profile image
AibnuHibban

Are you routing the controller correctly?
If there is an error what is the error?

Collapse
 
oceanrational profile image
VikramJS

Well. It's good you trying it on newer version. unfortunatly i havent tried yet. I hope someone will definitly answer this.

Collapse
 
lootfi profile image
Lotfi

Maybe your login form action is not making a request to your LoginController?

Route::post('authenticate', [LoginController::class, 'authenticate'])->name('authenticate');
<form method="POST" action="{{ route('authenticate') }}">