我为此花费了无数小时。通过互联网浏览,找不到解决方案。数据正在通过表单传递,但不会通过数据库进行身份验证。密码在注册时也会被散列。 我已经转储了输入,并且凭证已发布,但将通过数据库进行身份验证。感谢您的任何帮助!
路线
Route::get('/login', function() {
return view('pages.login');
});
Route::get('/register', function() {
return view('pages.register');
});
Route::post('/register_action', [
'uses' => 'RegisterController@store',
'as' => 'signup'
]);
Route::post('/login_action', [
'uses' => 'LoginController@LogIn',
'as' => 'signin'
]);
Route::get('/dashboard', [
'uses' => 'RegisterController@getDashboard',
'as' => 'dashboard'
]);
登录控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\User;
use Input;
class LoginController extends Controller
{
public function LogIn(Request $request) {
$data = array(
'email' => Input::get('useremail'),
'password' => Input::get('userpass'),
);
dd($data);
if(Auth::attempt($data)) {
return redirect()->route('dashboard');
}else {
echo "Fail";
}
}
}
注册控制器
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Input;
class RegisterController extends Controller
{
public function getDashboard() {
return view('pages.dashboard');
}
public function store(Request $request) {
$username = $request['username'];
$email = $request['email'];
$first_name = $request['userfname'];
$last_name = $request['userlname'];
$password = bcrypt($request['password']);
$user = new User();
$user->email = $email;
$user->username = $username;
$user->firstname = $first_name;
$user->lastname = $last_name;
$user->password = $password;
$user->save();
return redirect()->route('dashboard');
}
}
答案 0 :(得分:0)
您应该检查数据库迁移。密码静默至少需要120个字符。