瀏覽代碼

【Add】登录后台优化

liuxiangxin 4 月之前
父節點
當前提交
880564960c
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      app/Http/Controllers/Admin/Login.php

+ 6 - 3
app/Http/Controllers/Admin/Login.php

@@ -26,10 +26,13 @@ class Login extends Admin {
 			// 验证
 			if( !$username || !$code )		return json_send(['code'=>'error','msg'=>'用户名验证码必填']);
 			// 查询用户
-			$uid							= $AdminUser->orWhere('username',$username)->orWhere('phone',$username)->value('uid');
+			$admin							= $AdminUser->orWhere('username',$username)->orWhere('phone',$username)->first(['uid','username','phone','status','password','insert_time','update_time']);
+			// 用户不存在
+			if( !$admin ) 					return json_send(['code'=>'error','msg'=>'用户名不存在或已被停用']);
+			// 用户不存在
+			if( $admin['status'] ) 			return json_send(['code'=>'error','msg'=>'用户名不存在或已被停用']);
 			// 获取数据
-			$admin							= $AdminUser->getOne($uid);
-			$adminRule						= $AdminRule::query()->where('admin_uid',$uid)->first();
+			$adminRule						= $AdminRule::query()->where('admin_uid',$admin['uid'])->first();
 			// 用户不存在
 			if( !$admin || $admin['status'] ) return json_send(['code'=>'error','msg'=>'用户名不存在或已被停用']);
 			// 比对密码