加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – Laravel 5 – 更改默认登录操作

发布时间:2020-12-14 19:56:36 所属栏目:大数据 来源:网络整理
导读:我正在使用Laravel 5.0内置身份验证控制器.但是,除了进行身份验证之外,我还想在登录期间添加一些操作,例如更新另一个表.我似乎无法找到我应该写这样的代码的地方. 对于注册,我在“服务”文件夹下的“Registrar.php”文件中添加了我想要的内容.我怎么能登录?
我正在使用Laravel 5.0内置身份验证控制器.但是,除了进行身份验证之外,我还想在登录期间添加一些操作,例如更新另一个表.我似乎无法找到我应该写这样的代码的地方.

对于注册,我在“服务”文件夹下的“Registrar.php”文件中添加了我想要的内容.我怎么能登录?

提前致谢.

您可以在AuthController.php中添加以下函数来覆盖AuthenticatesAndRegistersUsers特性的默认函数.你可以根据需要改变它.
/**
 * Handle a login request to the application.
 *
 * @param  IlluminateHttpRequest  $request
 * @return IlluminateHttpResponse
 */
public function postLogin(Request $request)
{
    $this->validate($request,[
        'email' => 'required|email','password' => 'required',]);
    $credentials = $request->only('email','password');
    if ($this->auth->attempt($credentials,$request->has('remember')))
    {
        return redirect()->intended($this->redirectPath());
    }
    return redirect($this->loginPath())
                ->withInput($request->only('email','remember'))
                ->withErrors([
                    'email' => $this->getFailedLoginMessage(),]);
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读