1

I am using Laravel 5.4. I ran the make:auth command to scaffold out my auth controllers and views. I can register a new account without issue as it is showing up in my database. However when I try to login, the login page simply refreshes without any errors being thrown. In the login controller I have the redirect set to '/home' but this isn't happening. Any idea what could be causing this? I have a feeling this is because I made the required tweaks to allow users to login with a username rather than email. But I'm not sure what is causing my login not to work when everything else works fine.

Below is my login controller.

use AuthenticatesUsers;

/**
 * Where to redirect users after login.
 *
 * @var string
 */
protected $redirectTo = '/home';

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest', ['except' => 'logout']);
}


public function username()
{
    return 'username';
}

}

Dan Green
  • 23
  • 1
  • 4

3 Answers3

0

Once you've run php artisan make:auth you need to also run the migrations with php artisan migrate have you done this?

ThatCoderGuy
  • 657
  • 4
  • 10
0

Do a quick check to see if the route is being handled.

You might have to add Auth::routes(); in your web.php

Resource: laravel 5.3 new Auth::routes()

Jon Tan
  • 1,461
  • 3
  • 17
  • 33
0

I had this problem using Laravel 8.0 and found no helpful response over the internet... until I taught of checking the APP_URL set in my env...

Because I have other apps set up on other ports on the same localhost, I simply changed APP_URL from http://localhost to http://localhost:8003/, i.e, specifying the port this App is on.

Other steps I took that may contributes include generating new APP_KEY and refreshing my migration.

It's been many years, but, this took my 3 days to figure... I hope it helps someone.

Platinum
  • 68
  • 10