一个 Auth 登录的问题

出现的问题:
·填写好账号密码验证码都正确的情况下直接还在原来页面,在次填写账号密码验证码后就正常了。登录成功。
地址:https://www.5xdns.com/login

html登录代码

<form action="" method="POST" role="form" class="mt15" enctype="multipart/form-data">
                                    @csrf
                                    <div class="form-group">
                                        <label for="mail" class="control-label">邮箱</label>
                                        <input type="text" class="form-control" onfocus="document.getElementById('i1').innerHTML=''" id="email" name="email" required="" placeholder="邮箱" value="{{ old('email') }}">
                                        <i class="text-warning" id="i1" style="color: red">{{$errors->first('email')}}</i>
                                    </div>
                                    <div class="form-group">
                                        <label for="password" class="control-label">密码</label>
                                        <input type="password" class="form-control" onfocus="document.getElementById('i2').innerHTML=''" name="password" required="" placeholder="不少于 8 位 不大于 8 位的密码">
                                        <i class="text-warning" id="i2" style="color: red">{{$errors->first('password')}}</i>
                                    </div>
                                    <div class="form-group">
                                        <label for="password" class="control-label">验证码</label>
                                        <div class="captchaInput mb10">
                                            <input type="text" class="form-control" onfocus="document.getElementById('i3').innerHTML=''" name="captcha" placeholder="右侧的验证码" style="width:50%; display: inline; margin-right: 15px;" required="'">
                                            <span class="mt10">
                                        <a id="loginReloadCaptcha" href="javascript:void(0)">
                                        <img src="{{ captcha_src('math') }}" class="cap" width="135" height="34" onclick="this.src='{{ captcha_src('math') }}?tm='+Math.random()""></a>
                                        </span>
                                        </div>
                                        <i class="text-warning" id="i3" style="color: red">{{$errors->first('captcha')}}</i>
                                    </div>
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" name="online"> 记住我
                                        </label>
                                    </div>
                                    <div class="form-group clearfix">
                                        <button type="submit" class="btn-block btn btn-primary pl20 pr20 pull-right" style="background-color: #009a61" onclick="">
                                            登陆
                                        </button>
                                    </div>
                                    <div class="form-group clearfix">
                                        <div class="pull-left">
                                            <a href="{{ route('register') }}">尚未账号?</a>
                                        </div>
                                        <div class="pull-right">
                                            <a href="{{ route('seed') }}">忘记密码?</a>
                                        </div>
                                    </div>
                                </form>

controller代码

public function login(Request $request){
        if ($request->isMethod('post')){
            $this->validate($request,[
                'email'     =>  'required|email',
                'password'  =>   'required|between:8,32',
                'captcha'   =>  'required|between:2,4|captcha',
            ],[
                'captcha'   =>  ':attribute 错误',
            ],[
                'captcha'   =>  '验证码'
            ]);
            $date = $request->only('email','password');
            $requests = Auth::attempt($date,$request->get('online'));
            if($requests){
                if (Auth::user()->activation == '1'){
                    Auth::logoutOtherDevices($request->input('password')); //弹出其他登录用户
                    return redirect('user')->withErrors(['user'=>'登录成功']);
                }else{
                    Auth::logout();
                    return redirect('login')->withErrors(['login'=>'尚未激活账户,请在邮箱中查看,并激活。'])->withInput();
                }
            }else{
                return  redirect()->back()->withErrors(['login'=>'账号或者密码错误'])->withInput();
            }
        }else{
            return  view('home.login');
        }
    }
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

无法解决吗?

4年前 评论
讨论数量: 5

给个测试账号

4年前 评论
nfangxu

file

这个地方可以拿到用户信息吗

4年前 评论
chen900804 (楼主) 4年前

这个站的最佳答案可以随便设置吗?

4年前 评论
李小明 4年前

这个个代码写的太不规范了,很多没用的代码,看到一半不想继续看了。建议把论坛内的1.2.5教程 学一遍,例如未验证邮箱自动跳转 Laravel这些都给你写好 未学之前想做个博客,学完之后 只想做个app

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!