在我的laravel项目中,我在登录后检查状态和verified_email。但是显示用户名密码错误不匹配只是不检查登录后连续加载页面时出现的错误代码。
sessioncontroller
<?php
namespace App\Http\Controllers;
use Request;
use Response;
//----models--------
use App\Site;
use App\Jobs;
use Auth;
use DB;
use Validator;
use Redirect;
use Illuminate\Support\MessageBag;
class SessionController extends Controller {
public function index(){
return Redirect::to('login');
}
public function store()
{
$input = Request::only('username', 'email', 'password');
$credentials = [
'username' => Request::get('username'),
'password' => Request::get('password')
];
if (!Auth::attempt($credentials))
{
return Redirect::back()->with('alert-danger', 'Username or password do not match.');
}
else
{
if (Auth::user()->verified_email != 1) {
Auth::logout();
return Redirect::back()->with('alert-danger', 'Please verify your email.');
}
if (Auth::user()->status != 'A') {
Auth::logout();
return Redirect::back()->with('alert-danger', 'Your Account is disabled.Please contact your Administrator.');
}
$credentials_last_login = [
'last_login_at' => '',
'username' => array_get('username', $input, ' '),
'password' => array_get('password', $input, ' ')
];
if (Auth::attempt($credentials_last_login))
{
return redirect('/change_password');
}
else
{
return redirect('/properties');
}
}
}
}
当用户名密码不匹配时,它会发出错误提示,但当verified_email不是1且状态不是活动状态而不是显示错误时才会加载它。
答案 0 :(得分:1)
您的密码存储为哈希,但我认为您的密码是明确的 - 请尝试:
'password' => Hash::make($request->password)