laravel 5.1身份验证尝试登录身份验证


laravel 5.1 auth attempt login authenticaton

我在laravel 5中工作,在身份验证登录方面遇到困难。

我无法登录(使用正确的用户和通行证)并再次重定向到"登录"页面,而不是我想要的页面。

phpmyadmin中的表名为"users",因此使用Auth是正确的。

为什么它不起作用

<?php namespace App'Http'Controllers;
use Auth; 
// product é a pasta e o index é a pagina 
class BackendControlador extends Controller {
    public function index() {
    $email = 'email';
    $password = 'password';
    if (Auth::attempt(['email' => $email, 'password' => $password, 'acesso' => 1])) {
             return redirect()->intended('backend/dashboard.index');
        } elseif (Auth::attempt(['email'=> $email, 'password' => $password, 'acesso' => 0])) {
            return redirect()->intended('welcome');
        } else {
            return view('auth/login');
        }
    }
    public function portfolio() { 
        return view('backend/portfolio.index'); 
    }       
}

我的路线代码:

Route::get('/', function () {
    return view('welcome'); 
});
Route::get('backend','BackendControlador@index');
Route::get('backend/portfolio','BackendControlador@portfolio');
// Authentication routes...
Route::get('auth/login', 'Auth'AuthController@getLogin');
Route::post('auth/login', 'Auth'AuthController@postLogin');
// Authentication routes...
Route::get('auth/logout', 'Auth'AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth'AuthController@getRegister');
Route::post('auth/register', 'Auth'AuthController@postRegister');

问题是

  1. 代码行不接受您发送的变量,因此只有当您的用户名等于电子邮件,密码等于数据库中的密码时,您才会登录。

    $email = 'email';
    $password = 'password';
    

把它改成类似的东西

    $email  = Request::input('email'),
    $pass   = 'Hash::make(Request::input('password'))
  1. 您必须使用请求

     use Illuminate'Support'Facades'Request;
    

    use Request;
  1. 正如我在评论中建议的那样,使用bestmomo
  1. 编辑json文件以要求

    "bestmomo/scafold": "dev-master"

  2. 使用命令更新您的作曲家

composer update

3.下一个需要的步骤是将服务提供商添加到config/app.hp:

Bestmomo'Scafold'ScafoldServiceProvider::class,

  1. 发布

php artisan vendor:publish