Php Laravel 5.7-登录不';t登录用户
我三天前开始学习拉威尔,我遇到了一个无法解决的问题 当我注册一个用户时,表单工作,用户登录 注销也可以,但是当我登录已经注册的用户时,Laravel不会让他登录。相反,它将用户引导回主页(或我在Authenticate.php目录下设置的Authenticate.php文件的任何路径) 下面,我将在必要的文件上显示我的代码: 登录视图文件Php Laravel 5.7-登录不';t登录用户,php,laravel,laravel-5.7,Php,Laravel,Laravel 5.7,我三天前开始学习拉威尔,我遇到了一个无法解决的问题 当我注册一个用户时,表单工作,用户登录 注销也可以,但是当我登录已经注册的用户时,Laravel不会让他登录。相反,它将用户引导回主页(或我在Authenticate.php目录下设置的Authenticate.php文件的任何路径) 下面,我将在必要的文件上显示我的代码: 登录视图文件 <form method="POST" action="{{ route('login') }}"> @csrf <input ty
<form method="POST" action="{{ route('login') }}">
@csrf
<input type="email" placeholder="example@me.com" class="email form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="" required autofocus>
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
<input type="password" placeholder="Password" class="pwd form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" value="" required>
@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}</a>
@endif
<div class="remember_me_wrapper input">
<input type="checkbox" id="remember_me" class="checkbox" name="remember_me" value="scales" />
<label class="remember_me_label" for="remember_me" {{ old('remember') ? 'checked' : '' }}>
<span></span>Remember Me
</label>
</div>
<input type="submit" name="submit" class="submit" value="Log in">
</form>
非常感谢您的帮助 在\u construct()
方法中,它应该是注销
而不是注销
,或者在检查用户凭据时是否散列了密码。
希望这有帮助:)在\uu construct()
方法中,它应该是注销
而不是注销
,或者在检查用户凭据时是否散列了密码。
希望这对您有所帮助:)您可以将login()函数从AuthenticatesUsers.php(/laravel/framework/src/illighte/Foundation/Auth/AuthenticatesUsers.php)复制到LoginController,然后向该函数添加调试代码以查看它的位置fails@MichailStrokin我只是那样做了。我认为您提到的这个函数中唯一相关的代码是
$this->validateLogin($request)代码>。我与其他人进行了检查,但没有发现任何失败。请也上传您的注册码。您可以从AuthenticatesUsers.php(/laravel/framework/src/illighte/Foundation/Auth/AuthenticatesUsers.php)复制login()函数添加到LoginController,然后将调试代码添加到该函数,以查看它的位置fails@MichailStrokin我只是那样做了。我认为您提到的这个函数中唯一相关的代码是$this->validateLogin($request)代码>。我和其他人核实过了,但是我没有看到他们有任何失败。请上传你的注册码。欢迎!我使用Laravel的默认登录方式。我不知道在哪里可以找到它。你能再解释一下吗?如果你使用默认的登录方式,那么你不需要在控制器或视图的任何文件中进行更改。您只需更改.env文件配置。在这里,您在LoginController和web.php中也做了更改。欢迎!我使用Laravel的默认登录方式。我不知道在哪里可以找到它。你能再解释一下吗?如果你使用默认的登录方式,那么你不需要在控制器或视图的任何文件中进行更改。您只需要更改.env文件的配置。在这里,您在LoginController和web.php中也做了更改。
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Valiator;
use Auth;
use Illuminate\Http\Request;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/';
public function __construct()
{
$this->middleware('guest')->except('logouts');
}
public function logout(Request $request) {
Auth::logout();
return redirect('/');
}
public function checkLogin(Request $request){
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:8',
]);
}
}
Route::group(['middleware' => ['web']], function (){
Route::resource('/', "BlogController");
Route::get('auth/login', 'Auth\LoginController@getLogin');
Route::post('auth/login', 'Auth\LoginController@login');
Route::get('/logout', '\App\Http\Controllers\Auth\LoginController@logout')->name('logout' );
//register
Route::get('auth/register', 'Auth\RegisterController@getRegister');
Route::post('auth/register', 'Auth\RegisterController@postRegister');
Auth::routes();
Route::any('{catchall}', function($page) {
abort(404);
} )->where('catchall', '(.*)');
});