Ver Fonte

假注销

lizhen_gitee há 3 anos atrás
pai
commit
50f445ea11
2 ficheiros alterados com 16 adições e 0 exclusões
  1. 12 0
      application/api/controller/User.php
  2. 4 0
      application/common/library/Auth.php

+ 12 - 0
application/api/controller/User.php

@@ -887,6 +887,18 @@ class User extends Api
 //        $this->success("更新成功!");
     }
 
+    //假注销
+    public function cancleUser(){
+        if (!$this->request->isPost()) {
+            $this->error(__('Invalid parameters'));
+        }
+        //退出im
+        $tenIm = new Tenim();
+        $tenIm->loginoutim($this->auth->id);
 
+        Db::name('user')->where('id',$this->auth->id)->update(['status'=>-1]);
 
+        $this->auth->logout();
+        $this->success('注销成功');
+    }
 }

+ 4 - 0
application/common/library/Auth.php

@@ -355,6 +355,10 @@ class Auth
             return false;
         }
 
+        if ($user->status == -1) {
+            $this->setError('账户已注销');
+            return false;
+        }
         if ($user->status != 1) {
             $this->setError('Account is locked');
             return false;