[英]laravel 5.1 auth attempt login authenticaton
我在laravel 5中工作,無法進行身份驗證登錄。
我無法登錄(使用正確的用戶並通過)並再次重定向到“登錄”頁面,而不是我想要的頁面。
我在phpmyadmin中的表稱為“用戶”,因此使用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');
問題是
代碼行未使用您發送的變量,因此只有在用戶名等於電子郵件地址且密碼等於數據庫中密碼的情況下,您才能登錄。
$email = 'email'; $password = 'password';
將其更改為
$email = Request::input('email'),
$pass = \Hash::make(Request::input('password'))
您將不得不使用請求
use Illuminate\\Support\\Facades\\Request;
要么
use Request;
編輯您的json文件以要求
"bestmomo/scafold": "dev-master"
使用命令更新您的作曲家
composer update
3.下一步需要將服務提供者添加到config / app.php中:
Bestmomo\\Scafold\\ScafoldServiceProvider::class,
- 發布
php artisan vendor:publish
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.