generate the current restore key

@param User	$user
@return string
11570
public function restore_key( $user ) 
	{
		return \CCStr::hash( $user->password.'@'.$user->{$this->config->user_key}.'%'.\CCIn::client()->agent );
	}
792486
protected function getNewValues(User $user)
    {
        $newProps = new UserUpdater();
        $this->logger->section('Editing user ' . $user->getEmail() . ' (' . $user->getUsername() . ')');
        $this->logger->comment('leave empty to keep unchanged');
        $newProps->setUsername($this->ask(new Question('Username', $user->getUsername())));
        $newProps->setEmail($this->ask(new Question('E-mail address', $user->getEmail())));
        $password = $this->ask(new Question('Password', '***'));
        // replace default *** value if empty is given
        $newProps->setPassword($password !== '***' ? $password : '');

        return $newProps;
    }
330996
protected function getUserLink(User $user = null)
    {
        if (!$user) {
            return '<strong>' . t('Deleted User') . '</strong>';
        }

        $link = $this->getUrlResolver()->resolve(['/dashboard/users/search', $user->getUserID()]);
        $name = h($user->getUserName());
        return "<a href='$link'><strong>$name</strong></a>";
    }
889958
protected function getUserId($user)
    {
        if (is_null($user))
        {
            $user = auth()->user();
        }

        if ($user instanceof Model)
        {
            $user = $user->getKey();
        }

        return $user;
    }
178960
public function GenerateSmsToken($user = '') {
        $userName = $user;
        $nowEpoch = time();
        $smsNowSteps = $nowEpoch;
        $smsDigits = 6;
        $userTokenSeed = substr(md5(date("YmdHis").mt_rand(100000,999999)),0,20).substr(md5(mt_rand(100000,999999).date("YmdHis")),0,20);
        $smsSeedBin = hex2bin(md5('sMs'.$this->GetEncryptionKey().$userTokenSeed.$userName.$nowEpoch));
        $smsToken = $this->GenerateOathHotp($smsSeedBin,$smsNowSteps,$smsDigits);
        $smsNiceToken = $this->ConvertToNiceToken($smsToken);
        return $smsNiceToken;
    }
613705
protected function sendPasswordResetEmail(User $user)
    {
        $email = $user->email;

        /** @var \DreamFactory\Core\User\Services\User $parent */
        $parent = $this->getService();

        if (!empty($parent->passwordEmailServiceId)) {
            try {
                /** @var EmailServiceInterface $emailService */
                $emailService = ServiceManager::getServiceById($parent->passwordEmailServiceId);

                if (empty($emailService)) {
                    throw new ServiceUnavailableException("Bad email service identifier.");
                }

                $data = [];
                if (!empty($parent->passwordEmailTemplateId)) {
                    // find template in system db
                    $template = EmailTemplate::whereId($parent->passwordEmailTemplateId)->first();
                    if (empty($template)) {
                        throw new NotFoundException("Email Template id '{$parent->passwordEmailTemplateId}' not found");
                    }

                    $data = $template->toArray();
                }

                if (empty($data) || !is_array($data)) {
                    throw new ServiceUnavailableException("No data found in default email template for password reset.");
                }

                $data['to'] = $email;
                $data['content_header'] = 'Password Reset';
                $data['first_name'] = $user->first_name;
                $data['last_name'] = $user->last_name;
                $data['name'] = $user->name;
                $data['phone'] = $user->phone;
                $data['email'] = $user->email;
                $data['link'] = url(\Config::get('df.confirm_reset_url')) .
                    '?code=' . $user->confirm_code .
                    '&email=' . $email .
                    '&username=' . $user->username .
                    '&admin=' . $user->is_sys_admin;
                $data['confirm_code'] = $user->confirm_code;

                $bodyHtml = array_get($data, 'body_html');
                $bodyText = array_get($data, 'body_text');

                if (empty($bodyText) && !empty($bodyHtml)) {
                    $bodyText = strip_tags($bodyHtml);
                    $bodyText = preg_replace('/ +/', ' ', $bodyText);
                }

                $emailService->sendEmail($data, $bodyText, $bodyHtml);

                return true;
            } catch (\Exception $ex) {
                throw new InternalServerErrorException("Error processing password reset.\n{$ex->getMessage()}");
            }
        }

        return false;
    }
319892
private function getUserKey(PKEncryptionEnabledUserInterface $user)
    {
        $pkiKey = $this->findKeyByUser($user);

        if (!$pkiKey) {
            $userId = $user->getId();
            $userClass = $this->getUserClass($user);

            $pkiKey = new PKIPrivateKey();
            $pkiKey->setUserClass($userClass);
            $pkiKey->setUserId($userId);
        }

        return $pkiKey;
    }
197266
public function edit(User $user)
    {
        return $this->makeResponse('edit', [
            'user' => $user,
            'roles' => $this->roles,
            'x_fields' => $this->x_fields,
        ]);
    }
1279004
public function getPasswordResetKey(\Gems_User_User $user)
    {
        $model = new \MUtil_Model_TableModel('gems__user_passwords');
        \Gems_Model::setChangeFieldsByPrefix($model, 'gup', $user->getUserId());

        $data['gup_id_user'] = $user->getUserLoginId();
        $filter = $data;

        if ((0 == ($this->hoursResetKeyIsValid % 24)) || \Zend_Session::$_unitTestEnabled) {
            $filter[] = 'ADDDATE(gup_reset_requested, ' . intval($this->hoursResetKeyIsValid / 24) . ') >= CURRENT_TIMESTAMP';
        } else {
            $filter[] = 'DATE_ADD(gup_reset_requested, INTERVAL ' . $this->hoursResetKeyIsValid . ' HOUR) >= CURRENT_TIMESTAMP';
        }
        $row = $model->loadFirst($filter);
        if ($row && $row['gup_reset_key']) {
            // Keep using the key.
            $data['gup_reset_key'] = $row['gup_reset_key'];
        } else {
            $data['gup_reset_key'] = hash('sha256', time() . $user->getEmailAddress());
        }
        $data['gup_reset_requested'] = new \MUtil_Db_Expr_CurrentTimestamp();

        // Loop for case when hash is not unique
        while (true) {
            try {
                $model->save($data);

                return $data['gup_reset_key'];

            } catch (\Zend_Db_Exception $zde) {
                $data['gup_reset_key'] = hash('sha256', time() . $user->getEmailAddress());
            }
        }
    }
554322
public function getUserEntity($user)
    {
        $result = null;
        if ($user instanceof UserEntity) {
            $result = $user;
        } else {
            $u = $this->getUser($user);
            if ($u !== null) {
                $result = $this->app->make(EntityManager::class)->find(UserEntity::class, $u->getUserID());
            }
        }

        return $result;
    }
490137
public function serializeToString(User $user)
    {
        $serializedUser = $this->serialize($user);

        foreach ($serializedUser as $key => $value) {
            $serializedUser[$key] = base64_encode($value);
        }

        return base64_encode(json_encode($serializedUser));
    }
1290913
public function updateUser(User $user)
    {
        $query = $this->handler->createUpdateQuery();
        $query
            ->update($this->handler->quoteTable('ezuser'))
            ->set(
                $this->handler->quoteColumn('login'),
                $query->bindValue($user->login)
            )->set(
                $this->handler->quoteColumn('email'),
                $query->bindValue($user->email)
            )->set(
                $this->handler->quoteColumn('password_hash'),
                $query->bindValue($user->passwordHash)
            )->set(
                $this->handler->quoteColumn('password_hash_type'),
                $query->bindValue($user->hashAlgorithm)
            )->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('contentobject_id'),
                    $query->bindValue($user->id, null, \PDO::PARAM_INT)
                )
            );
        $query->prepare()->execute();

        $query = $this->handler->createUpdateQuery();
        $query
            ->update($this->handler->quoteTable('ezuser_setting'))
            ->set(
                $this->handler->quoteColumn('is_enabled'),
                $query->bindValue($user->isEnabled, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('max_login'),
                $query->bindValue($user->maxLogin, null, \PDO::PARAM_INT)
            )->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('user_id'),
                    $query->bindValue($user->id, null, \PDO::PARAM_INT)
                )
            );
        $query->prepare()->execute();
    }
1186197
public function forUser($user)
    {
        $callback = function () use ($user)
        {
            return $user;
        };

        return new static(
            $this->container, $callback, $this->abilities,
            $this->policies, $this->beforeCallbacks, $this->afterCallbacks
        );
    }
526881
public function getUser($user)
    {
        $result = null;
        if ($user === 'current') {
            $u = new \User();
            if ($u->isRegistered()) {
                $result = $u;
            }
        } elseif (is_int($user) || (is_string($user) && is_numeric($user))) {
            $result = \User::getByUserID($user);
        } elseif ($user instanceof UserService) {
            $result = $user;
        } elseif ($user instanceof UserEntity) {
            $result = \User::getByUserID($user->getUserID());
        }

        return $result;
    }
1267897
public function regenerateApiKey(User $user)
    {
        $user->api_key = User::generateApiKey();
        $user->save();

        event(new UserRegeneratedApiTokenEvent($user));

        return cachet_redirect('dashboard.user');
    }
36864
public function findWorkspaceRootsByUser(User $user)
    {
        $builder = new ResourceQueryBuilder();
        $dql = $builder->selectAsArray()
            ->whereParentIsNull()
            ->whereInUserWorkspace($user)
            ->orderByPath()
            ->getDql();
        $query = $this->_em->createQuery($dql);
        $query->setParameters($builder->getParameters());

        return $this->executeQuery($query);
    }
24272
static function generateUserIdentifier( &$user )
    {
        if ( !$user )
        {
            $user = eZUser::currentUser();
        }
        $userIdentifierBase = false;
        if ( $user->attribute( 'is_logged_in' ) )
        {
            $userIdentifierBase = 'ezuser-' . $user->attribute( 'contentobject_id' );
            $userIdentifier = md5( $userIdentifierBase );
        }
        else
        {
            $userIdentifier = session_id();
            //$userIdentifierBase = 'ezuser-anonymous-' . eZSys::clientIP();
        }
        return $userIdentifier;
    }