修改登录验证失败不跳转的问题和验证码显示位置
This commit is contained in:
1 parent
db528a515f
commit
3084e8460a
3 files changed
+13
-10
No files matched your search
@@ -24,14 +24,12 @@ class YanZheng extends Controller
|
||||
}
|
||||
if( strlen($username)<1 )
|
||||
{
|
||||
// $this->redirect('/login',302);
|
||||
echo "<script>top.location.href='/login';</script>";
|
||||
}
|
||||
|
||||
// 检验用户名或密码是否正确
|
||||
$yz = action('login/index/check',['username'=>$username,'password'=>$password]);
|
||||
if($yz == null){
|
||||
// $this->error('请重新登录');
|
||||
if($yz['status'] == 0){
|
||||
echo "<script>top.location.href='login';</script>";
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class Index extends Controller
|
||||
// 验证用户名和密码
|
||||
$check = $this->check($data['username'],$data['password']);
|
||||
|
||||
if($check)
|
||||
if($check['status']==1)
|
||||
{
|
||||
|
||||
// 设置cookie值
|
||||
@@ -80,7 +80,7 @@ class Index extends Controller
|
||||
$data=['msg'=>'验证成功','status'=>1];
|
||||
}else{
|
||||
// 提示错误信息
|
||||
$data=['msg'=>'用户名或密码错误','status'=>0];
|
||||
$data=['msg'=>$check['msg'],'status'=>0];
|
||||
}
|
||||
|
||||
return json($data);
|
||||
@@ -98,8 +98,11 @@ class Index extends Controller
|
||||
|
||||
if($userinfo == null)
|
||||
{
|
||||
// 提示错误信息
|
||||
$this->error('帐号不存在');
|
||||
// 清除session(当前作用域)
|
||||
session(null);
|
||||
// 验证结果;
|
||||
$data=['msg'=>'用户名不存在或被禁用','status'=>0];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,13 +115,15 @@ class Index extends Controller
|
||||
session('userid', $userinfo->id);
|
||||
session('username', $username);
|
||||
session('password', $password);
|
||||
$data=['msg'=>'验证成功','status'=>1];
|
||||
}else{
|
||||
// 清除cookie
|
||||
cookie(null, 'think_');
|
||||
// 清除session(当前作用域)
|
||||
session(null);
|
||||
$data=['msg'=>'用户名或密码错误','status'=>0];
|
||||
}
|
||||
return $check;
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 生成验证码
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<input name="username" placeholder="用户名" type="text" lay-verify="required" class="layui-input" >
|
||||
<hr class="hr15">
|
||||
<input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
|
||||
<hr class="hr15">
|
||||
<img style="width: 100%" id="captchaimg" src="/verify" alt="captcha" onclick="javascript:this.src=this.src+'?rnd=' + Math.random();" />
|
||||
<hr class="hr15">
|
||||
<input name="captcha" id="captcha" lay-verify="required" placeholder="验证码" type="text" class="layui-input">
|
||||
<hr class="hr15">
|
||||
<img style="width: 100%" id="captchaimg" src="/verify" alt="captcha" onclick="javascript:this.src=this.src+'?rnd=' + Math.random();" />
|
||||
<hr class="hr15">
|
||||
<input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
|
||||
<hr class="hr20" >
|
||||
</form>
|
||||
|
||||
Reference in new issue
Block a user