Exemple #1
0
 public function signUp($data)
 {
     // 用户名或email被占用了
     if ($this->findUserByName($data['name']) || $this->findUserByName($data['email'])) {
         return false;
     }
     $salt = mt_rand(1000, 100000);
     // auth hash
     $password = $this->hash($data['password'], $salt);
     $user = new User();
     $user->name = $data['name'];
     $user->email = $data['email'];
     $user->salt = $salt;
     $user->password = $password;
     $user->reg_time = time();
     $user->last_sign_time = time();
     $user->signin_count = 0;
     $user->region = 0;
     $user->status = 0;
     // 0.未激活 1.激活并状态正常 2.已激活,未填写真实资料 3.用户主动申请锁定 4.作弊被锁定 5.注销
     $user->phone = 1;
     $user->last_sign_ip = 123123;
     if ($user->save() === true) {
         return true;
     } else {
         return false;
     }
 }
Exemple #2
0
 /**
  * 登录成功后,登录次数加1,更新最后登录时间
  *
  * @param \Pari\Models\User $user
  * @param string $password 明文密码
  */
 private function completeLogin(User $user)
 {
     //更新登录次数
     $user->User_login_num = $user->User_login_num + 1;
     //更新登录时间
     $user->User_old_login_time = $user->User_login_time;
     $user->User_login_time = time();
     //更新登录IP
     $user->User_old_login_ip = $user->User_login_ip;
     $user->User_login_ip = $this->getRequest()->getClientAddress();
     //保存
     $user->save();
 }