xxxrrrdddd il y a 3 ans
Parent
commit
c74d58dfa2

+ 2 - 2
application/common/library/Auth.php

@@ -214,10 +214,10 @@ class Auth
      * @param string $password 密码
      * @return boolean
      */
-    public function login($account, $password)
+    public function login($account, $password,$extra=[])
     {
         $field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username');
-        $user = User::where([$field => $account])->find();
+        $user = User::where([$field => $account])->where($extra)->find();
         if (!$user) {
             $this->setError('Account is incorrect');
             return false;

+ 1 - 1
application/sub/controller/Index.php

@@ -6,7 +6,7 @@ namespace app\sub\controller;
 class Index extends SubCommon
 {
     protected $noNeedLogin = [];
-    protected $noNeedRight = [];
+    protected $noNeedRight = '*';
     protected $layout = '';
 
     public function index()

+ 1 - 2
application/sub/controller/User.php

@@ -70,7 +70,6 @@ class User extends Frontend
             $this->success(__('You\'ve logged in, do not login again'), $url ? $url : url('user/index'));
         }
         if ($this->request->isPost()) {
-            $this->error('登录已禁用');
             $account = $this->request->post('account');
             $password = $this->request->post('password');
             $keeplogin = (int)$this->request->post('keeplogin');
@@ -98,7 +97,7 @@ class User extends Frontend
                 $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
                 return false;
             }
-            if ($this->auth->login($account, $password)) {
+            if ($this->auth->login($account, $password,['type'=>1])) {
                 $this->success(__('Logged in successful'), $url ? $url : url('user/index'));
             } else {
                 $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);