laravel5.3 登录以后出现空白页 注册不能跳转到主页, 登录操作验证出现空白页,刷新之后就正常了,

路由:web.php

Auth::routes();

登录方法:login()

public function login(Request $request)
    {
        $milkcaptcha = Session::get('milkcaptcha');
        if (trim($_POST['captcha']) != $milkcaptcha) {
            return back()->with('err', '验证码错误');
        }
        $this->validate($request, [
            $this->loginUsername() => 'required', 'password' => 'required',
        ]);
        $throttles = $this->isUsingThrottlesLoginsTrait();
        if ($throttles && $this->hasTooManyLoginAttempts($request)) {
            return $this->sendLockoutResponse($request);
        }

        $credentials = $this->getCredentials($request);
        if (Auth::attempt($credentials, $request->has('remember'))) {
            return $this->handleUserWasAuthenticated($request, $throttles);
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
//        echo "<pre>123";print_r(Session::all());exit;
        if ($throttles) {
            $this->incrementLoginAttempts($request);
        }
        if ($request->origin == 'wap') {
            $this->loginPath = 'site/login_wap';
        }
        return redirect($this->loginPath())
            ->withInput($request->only($this->loginUsername(), 'remember'))
            ->withErrors([
                $this->loginUsername() => $this->getFailedLoginMessage(),
            ]);
    }

注册方法使用ajax方式提交
js部分:

$.ajax({
            type:'POST',
            url: '/register',
            data: post_data,
            dataType: 'json',
            headers: {
                   'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            success:function(data){
                if(data.result=='success'){
                    showToasts('success', '注册成功,即将跳转到登录页面', '提示');
                    setTimeout(function () {
                        location.href="/home";
                    }, 1500);
                }else{
                    var html = "";
                    for(k in data){
                        html += "<li class=\"list-group-item list-group-item-danger\">" + data[k] + "</li>";
                    }
                    $('#err').html(html);
                }
            },
            error: function() {
                showToasts('error', '网络繁忙,稍后再试!', '提示');
            },
        })

注册register方法:

public function register(Request $request)
    {
        $this->validator($request->all())->validate();
        $user = $this->create($request->all());

//        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);
        Auth::login($user);

        $arr =array("result"=>'success');
        return Response::json($arr);
michacelliu
修改的评论也不能少于六个字哦!
JellyBool
修改的评论也不能少于六个字哦!
michacelliu 回复 JellyBool
修改的评论也不能少于六个字哦!
JellyBool
修改的评论也不能少于六个字哦!
michacelliu 回复 JellyBool
修改的评论也不能少于六个字哦!
michacelliu
修改的评论也不能少于六个字哦!