刷新用户基本信息

@since 0.0.1
@param {integer} $uid 用户id
@return {boolean}
@example \Yii::$app->wechat->refreshUser($uid);
761874
public function refreshUser($uid) {
		$user = WechatUser::findOne($uid);
		if(!$user) {
			throw new ErrorException('数据查询失败');
		}

		$data = $this->getData('/cgi-bin/user/info', [
			'access_token' => $this->getAccessToken(),
			'openid' => $user->openid,
			'lang' => \Yii::$app->language,
		]);

		$result = $this->errcode == 0;
		if($result) {
			$user->subscribe = $data['subscribe'];
			if($user->subscribe == 1) {
				$user->subscribed_at = $data['subscribe_time'];
				$user->name = $data['nickname'];
				$user->sex = $data['sex'];
				$user->country = $data['country'];
				$user->city = $data['city'];
				$user->province = $data['province'];
				$user->language = $data['language'];
				$user->headimgurl = $data['headimgurl'];
				$user->remark = $data['remark'];
				$user->groupid = $data['groupid'];
			}
			if(isset($data['unionid'])) {
				$user->unionid = $data['unionid'];
			}
			$user->save();
		}

		return $result;
	}
1175939
public function findOneByUidIgnoreHidden($uid)
    {
        $query = $this->createQuery();
        $query->getQuerySettings()->setIgnoreEnableFields(TRUE);
        //$query->getQuerySettings()->setRespectStoragePage(FALSE);

        $query->matching(
            $query->equals('uid', $uid )
        );

        return $query->execute()->getFirst();
    }
1280959
function changePassword($uid, $old_pwd, $new_pwd)
    {
        $table = table($this->login_table, $this->login_db);
        $table->primary = self::$userid;
        $_res = $table->gets(array('select' => self::$username . ',' . self::$password, 'limit' => 1, self::$userid => $uid));
        if (count($_res) < 1)
        {
            $this->errMessage = '用户不存在';
            $this->errCode = 1;
            return false;
        }

        $user = $_res[0];
        if ($user[self::$password] != self::makePasswordHash($user[self::$username], $old_pwd))
        {
            $this->errMessage = '原密码不正确';
            $this->errCode = 2;
            return false;
        }
        else
        {
            $table->set($uid, array(self::$password => self::makePasswordHash($user[self::$username], $new_pwd)), self::$userid);
            return true;
        }
    }
89963
public function update($uid)
    {
        if (!Input::has('user')) {
            return $this->jsonErrorResponse('"user" is required.');
        }

        $user = Subbly::api('subbly.user')->update($uid, Input::get('user'));

        return $this->jsonResponse(array(
            'user' => $this->presenter->single($user),
        ),
        array(
            'status' => array(
                'code'    => 200,
                'message' => 'User updated',
            ),
        ));
    }
1102819
public function check($uid = 0, $name = [], $relation = 'or'){

        // 是否开启权限开关 (或者 用户id为 1  超级管理员)
        if (empty($this->config['auth_on']) || $uid == 1){
            return true;
        }

        if (empty($uid) || empty($name)){
            return false;
        }

        //获取用户对应角色
        $groups = $this->getRoleUser($uid);
        if (empty($groups)){
            return false;
        }

        //如果用户角色有超级管理员直接验证成功
        if (in_array(1,$groups)){
            return true;
        }

        if (is_string($name)) {
            $name = strtolower($name);
            if (strpos($name, ',') !== false) {
                $name = explode(',', $name);
            } else {
                $name = array($name);
            }
        }

        // 获取该用户 对应 该规则名的权限列表
        $rules = $this->getRuleData($uid);

        if (empty($rules)){
            return false;
        }

        //用户信息
        $user = $this->getUserInfo($uid);

        foreach ($rules as $rule){
            if (!empty($rule['condition'])) { //根据condition进行验证

                $command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $rule['condition']);
                //dump($command);//debug
                @(eval('$condition=(' . $command . ');'));
                if ($condition) {
                    $list[] = strtolower($rule['name']);
                }
            }else{
                $list[] = strtolower($rule['name']);
            }
        }

        if ($relation == 'or' and !empty($list)) {
            return true;
        }
        $diff = array_diff($name, $list);
        if ($relation == 'and' and empty($diff)) {
            return true;
        }

        return false;
    }
1276842
protected function getUserId($iUserId = null)
    {
        if (!empty($iUserId)) {
            $iUid = (int) $iUserId;
        } elseif ($this->activeUser('id')) {
            $iUid = $this->activeUser('id');
        } else {
            $this->setError('No user ID set');
            return false;
        }

        return $iUid;
    }
270365
protected function refresh_info()
    {

        $this->pid   = (int)getmypid();
        $this->gid   = (int)getmygid();
        $this->inode = (int)getmyinode();
        $this->uid   = (int)getmyuid();
        $this->user  = (string)get_current_user();
        $this->uname = posix_uname();

        return true;
    }
181145
public function actionUpdate($id)
    {
        $roles = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description');
        $user_permit = array_keys(Yii::$app->authManager->getRolesByUser($id));
        $user = $this->findUser($id);
        //return $this->render('view', [
        //    'user' => $user,
        //    'roles' => $roles,
        //    'user_permit' => $user_permit,
         //   'moduleName' => Yii::$app->controller->module->id
        //]);


        return $this->render('update', [
            'user' => $user,
            'roles' => $roles,
           'user_permit' => $user_permit,
           'moduleName' => Yii::$app->controller->module->id
        ]);


/*        $user = $this->findUser($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }

        //роли
        Yii::$app->authManager->revokeAll($user->getId());
        if(Yii::$app->request->post('roles')){
            foreach(Yii::$app->request->post('roles') as $role)
            {
                $new_role = Yii::$app->authManager->getRole($role);
                Yii::$app->authManager->assign($new_role, $user->getId());
            }
        }
        return $this->redirect(Url::to(["/".Yii::$app->controller->module->id."/user/view", 'id' => $user->getId()]));*/
    }
1059639
public function actionCustomUpdate($id = '')
    {
        $model = Options::findOne(['id' => $id]);
        if (yii::$app->getRequest()->getIsPost()) {
            if ($model->load(yii::$app->getRequest()->post()) && $model->save()) {
                yii::$app->getSession()->setFlash('success', yii::t('cms', 'Success'));
                return $this->redirect(['custom']);
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= $v[0] . '<br>';
                }
                yii::$app->getResponse()->format = Response::FORMAT_JSON;
                return [
                    'err_msg' => $err,
                ];
            }
        } else {
            yii::$app->getResponse()->format = Response::FORMAT_HTML;
            echo '<div class="" id="editForm">';
            echo '<div class="ibox-content">';
            $form = ActiveForm::begin(['options' => ['name' => 'edit']]);
            echo $form->field($model, 'name')->textInput();
            echo $form->field($model, 'input_type')->dropDownList(Constants::getInputTypeItems());
            echo $form->field($model, 'tips')->textInput();
            echo $form->field($model, 'autoload')->dropDownList(Constants::getYesNoItems());
            echo $form->field($model, 'value')->textInput();
            echo $form->field($model, 'sort')->textInput();
            echo $form->defaultButtons();
            ActiveForm::end();
            echo '</div>';
            echo '</div>';
        }
    }
65306
public function updateUser($uid, $properties): UserRecord
    {
        $request = $properties instanceof Request\UpdateUser
            ? $properties
            : Request\UpdateUser::withProperties($properties);

        $request = $request->withUid($uid);

        $response = $this->client->updateUser($request);

        $uid = JSON::decode((string) $response->getBody(), true)['localId'];

        return $this->getUser($uid);
    }
901098
public function searchByUid($uid) {
		$results = $this->ldap->search($this->basedn,
			$this->search_username . '=' . $uid);
		return $results;
	}
1288946
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $oldSubmodulesParentUid = $model->parent_uid . '/{' . $model->id . '}';

        $post = Yii::$app->request->post();
        $loaded = $model->load($post);
        if ($loaded && $model->save()) {
            $newSubmodulesParentUid = $model->parent_uid . '/{' . $model->id . '}';
            $model->correctParents($oldSubmodulesParentUid, $newSubmodulesParentUid);

            //return $this->redirect(['view', 'id' => $model->id]);
            return $this->redirect(['index', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
839038
public static function getById($uid)
    {    
		if ($uid == USER_ANONYMOUS) return new User\Anonymous();
        $fields = self::getDbConnection()->fetchAssoc( 'SELECT * FROM '.User::TABLE.' WHERE id = ?', array( $uid ) );
        if (!$fields) throw new \Exception('User:'.$uid.' is not found'); 
        return self::fetch($fields);    
  	}
456232
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', '修改成功');
            return \myzero1\layui\helpers\Tool::redirectParent(['index']);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
474381
def chuid(name, uid):
    '''
    
    '''
    if not isinstance(uid, int):
        raise SaltInvocationError('uid must be an integer')
    pre_info = info(name)
    if not pre_info:
        raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
    if uid == pre_info['uid']:
        return True
    _dscl(
        ['/Users/{0}'.format(name), 'UniqueID', pre_info['uid'], uid],
        ctype='change'
    )
    # dscl buffers changes, sleep 1 second before checking if new value
    # matches desired value
    time.sleep(1)
    return info(name).get('uid') == uid
1193149
public function getUidAppid($uid = '', $type = "all") {
        $key  = md5($uid . md5($uid . 'thirdAuthorizeCallback') . "_wechat");
        $data = to_array(F($key, '[get]'));
        if ($data) {
            switch ($type) {
            case 'appid':
                return $data['authorizer_appid'];
                break;
            default:
                return $data;
                break;
            }
        } else {
            return false;
        }
    }
537078
protected function uid()
	{
		if ($this->uid === null) {
			$client = $this->getClient('common');

			$this->uid = $client->call('login', array(
				$this->database,
				$this->user,
				$this->password
			));
		}

		return $this->uid;
	}