Browse Source

注册权限初始化

zhangxiaobin 1 year ago
parent
commit
f0c0e22e2c
1 changed files with 7 additions and 1 deletions
  1. 7 1
      application/common/library/Auth.php

+ 7 - 1
application/common/library/Auth.php

@@ -195,7 +195,13 @@ class Auth
 
             //设置登录状态
             $this->_logined = true;
-
+            //初始化权限
+            $userPowerWhere['user_id'] = $user->id;
+            $userPowerData = Db::name('user_power')->where($userPowerWhere)->find();
+            if (empty($userPowerData)) {
+                $powerData = ['user_id' => $user->id];
+                Db::name('user_power')->insertGetId($powerData);
+            }
             //注册成功的事件
             Hook::listen("user_register_successed", $this->_user, $data);
             \app\common\model\NewBagHave::insert(["user_id" => $user->id, "createtime" => time()]);