did you write all your own login and register functionality?
Are the passwords hashed in the database?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I started learning about Laravel 3 days ago and I reached a problem which I cannot fix.
When I register a user, the form works and the user is logged in.
The logout also works, but when I login the user which has already registered, Laravel doesn't logs him in.
Below, I am showing my code on the necessary files:
login view file
<form method="POST" action="{{ route('login') }}">
@csrf
<input type="email" placeholder="[email protected]" class="email form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="" required autofocus>
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
<input type="password" placeholder="Password" class="pwd form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" value="" required>
@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
<div class="remember_me_wrapper input">
<input type="checkbox" id="remember_me" class="checkbox" name="remember_me" value="scales" />
<label class="remember_me_label" for="remember_me" {{ old('remember') ? 'checked' : '' }}>
<span></span>
Remember Me
</label>
</div>
</div>
</div>
<input type="submit" name="submit" class="submit" value="Log in">
</div>
</form>
Login Controller file:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Valiator;
use Auth;
use Illuminate\Http\Request;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logouts');
}
public function logout(Request $request) {
Auth::logout();
return redirect('/');
}
public function checkLogin(Request $request){
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:8',
]);
}
}
Routes (web.php)
Route::group(['middleware' => ['web']], function (){
Route::resource('/', "BlogController");
// ->condition('propability', 1);
Route::get('auth/login', 'Auth\LoginController@getLogin');
Route::post('auth/login', 'Auth\LoginController@login');
Route::get('/logout', '\App\Http\Controllers\Auth\LoginController@logout')->name('logout' );
//register
Route::get('auth/register', 'Auth\RegisterController@getRegister');
Route::post('auth/register', 'Auth\RegisterController@postRegister');
Auth::routes();
Route::any('{catchall}', function($page) {
abort(404);
} )->where('catchall', '(.*)');
});
Help will be much appreciated!
@CRONIX - Thank you! I created a new project in order to experiment with the Authentication system. Seemed like I didn't create a migration, but created the tables by myself. I didn't know that Laravel required you to create a migration for your users in order for the Authentication system to work. Thank you a lot for your help and also to @king_eke for trying!
Please or to participate in this conversation.