[英]Laravel login redirects back to login page
I'm a beginner to Laravel 5.5.* and I'm trying to create a login page. 我是Laravel 5.5。*的初学者,并且正在尝试创建登录页面。
whenever i click the login button i'm redirected back to the login form. 每当我单击登录按钮时,我都会被重定向回登录表单。
Here are my steps: 这是我的步骤:
php artisan make:auth
php artisan make:migration table_name_here
php artisan migrate
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Auth;
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 = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'firstname', 'lastname', 'email', 'password', 'department', 'phone', 'status', 'roleId',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
staffId, roleId, firstname, lastname, username, email, department, phone, status, remember_token, created_at, updated_at, password, staffId,roleId,名字,姓氏,用户名,电子邮件,部门,电话,状态,remember_token,created_at,updated_at,密码,
只需重新启动apache服务器,然后再次运行php artisan serve命令,这可能会帮助您解决问题。
I had the same problem that the login redirected to the login page without any errors. 我遇到了同样的问题,即登录名重定向到登录页面没有任何错误。
For me I didn't had any name tag in my input field of my form eg So it didn't know what data to send the in the request 对我而言,我在表单的输入字段中没有任何名称标签,例如,因此它不知道在请求中发送什么数据
<input type="email">
<input type="password">
Should be 应该
<input type="email" name="email">
<input type="password" name="password">
因此,当我在本地开发环境中的session.php中设置SESSION_DOMAIN'NULL'时,我能够解决此问题。
I got the same issue having SESSION_SECURE_COOKIE=true
set while migrating from an old to a new production server to a new one. 从旧服务器向新生产服务器迁移到新服务器时,设置
SESSION_SECURE_COOKIE=true
时遇到相同的问题。 HTTPS was not set up set. 未设置HTTPS。
By removing SESSION_SECURE_COOKIE=true
, logging in started working again. 通过删除
SESSION_SECURE_COOKIE=true
,登录可以再次开始工作。
Of course, set up HTTPS and add the env var back before actually migrating servers for real. 当然,在实际迁移服务器之前,先设置HTTPS并添加env var。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.