简体   繁体   中英

Laravel Auth Login Page Just Refreshes

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';
}

}

一旦运行了php artisan make:auth您还需要使用php artisan migrate migration运行迁移?

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()

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/ , ie, 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM