把我的头发拉出来似乎是一项简单的任务。我在使用以下代码时使用username
而不是:email
AuthController
/**
* Set the login system to use username instead of email address
* @var string
*/
protected $username = 'username';
这已经运行了很长时间(当我不打算让用户激活他们的帐户时)。但是,现在我需要用户激活他们的帐户,我知道我需要在登录时进行额外的检查,然后他们才能看到他们的仪表板。
我已将以下postLogin()
方法修改为我认为正确的方法:
public function postLogin(Request $request)
{
$this->validate($request, [
'username' => 'required', 'password' => 'required',
]);
$credentials = $request->only('username', 'password');
$credentials = array_add($credentials, 'confirmed', '1');
if ($this->auth->attempt($credentials, $request->has('remember')))
{
return redirect()->intended($this->redirectPath());
}
return redirect($this->loginPath())
->withInput($request->only('username', 'remember'))
->withErrors([
'username' => $this->getFailedLoginMessage(),
]);
}
但我得到的只是以下错误:
Undefined property: App\Http\Controllers\Auth\AuthController::$auth
我做错了什么?
安迪