Adds Administrator account for inherited User Identity.
@return string result message.
@since 0.2
337139
protected function addInheritedAdmin()
    {
        if (empty($this->module->adminId)) {
            $this->type = self::TYPE_WARNING;
            return Yii::t('podium/flash', 'No administrator privileges have been set!');
        }
        try {
            $identity = Podium::getInstance()->user->identityClass;
            $inheritedUser = $identity::findIdentity($this->module->adminId);
            if (!$inheritedUser) {
                throw new Exception('Can not find administrator account!');
            }
            $userNameField = $this->module->userNameField;
            if ($userNameField !== null && empty($inheritedUser->$userNameField)) {
                throw new Exception('Can not find administrator username!');
            }
        } catch (Exception $e) {
            return $this->returnWarning(Yii::t('podium/flash', 'Cannot find inherited user of given ID. No administrator privileges have been set.'));
        }

        $transaction = $this->db->beginTransaction();
        try {
            $admin = new User();
            $admin->setScenario('installation');
            $admin->setAttributes([
                'inherited_id' => $this->module->adminId,
                'username' => $userNameField ? $inheritedUser->$userNameField : self::DEFAULT_USERNAME,
                'status' => User::STATUS_ACTIVE,
                'role' => User::ROLE_ADMIN,
            ], false);
            if (!$admin->save()) {
                throw new Exception(VarDumper::dumpAsString($admin->errors));
            }
            if (!$this->authManager->assign($this->authManager->getRole(Rbac::ROLE_ADMIN), $admin->id)) {
                throw new Exception('Error during Administrator privileges setting!');
            }
            $transaction->commit();
            return $this->returnSuccess(Yii::t('podium/flash', 'Administrator privileges have been set for the user of ID {id}.', [
                'id' => $this->module->adminId
            ]));
        } catch (Exception $e) {
            $transaction->rollBack();
            return $this->returnError($e->getMessage(), __METHOD__,
                Yii::t('podium/flash', 'Error during account creating')
            );
        }
    }
358762
public function getAuthority(): string
    {
        if ($this->host == '') {
            return '';
        }

        $authority = $this->host;
        if ($this->user != '') {
            $authority = $this->user.'@'.$authority;
        }

        if ($this->port !== null && !$this->isDefaultPort($this->scheme, $this->port)) {
            $authority .= ':'.$this->port;
        }

        return $authority;
    }
912229
public function create()
    {
        /**
         * @var AdminUserInterface $adminUser
         */
        $classNamespace = $this->getEntityNamespace();
        $adminUser = new $classNamespace();
        $adminUser
            ->setGender(ElcodiUserProperties::GENDER_UNKNOWN)
            ->setToken($this->generator->generate(2))
            ->setEnabled(true)
            ->setCreatedAt($this->now());

        return $adminUser;
    }
258137
public function authenticate()
    {
        $confirm = $this->getServiceLocator()
                        ->get( 'Grid\User\Model\ConfirmHash' );

        if ( $confirm->has( $this->hash ) )
        {
            $user = $this->getModel()
                         ->findByEmail( $confirm->find( $this->hash ) );

            if ( ! empty( $user ) )
            {
                $user->confirmed = true;

                if ( $user->save() )
                {
                    $confirm->delete( $this->hash );
                    return new Result( Result::SUCCESS, $user );
                }
                else
                {
                    return new Result( Result::FAILURE_UNCATEGORIZED, null );
                }
            }
        }
        else
        {
            return new Result( Result::FAILURE_CREDENTIAL_INVALID, null );
        }

        return new Result( Result::FAILURE_IDENTITY_NOT_FOUND, null );
    }
699725
public function user()
    {
        if (! $this->hasNecessaryVerifier()) {
            throw new InvalidArgumentException('Invalid request. Missing OAuth verifier.');
        }

        $token = $this->getToken();

        $user = $this->server->getUserDetails(
            $token, $this->shouldBypassCache($token->getIdentifier(), $token->getSecret())
        );

        $instance = (new User)->setRaw($user->extra)
                ->setToken($token->getIdentifier(), $token->getSecret());

        return $instance->map([
            'id' => $user->uid,
            'nickname' => $user->nickname,
            'name' => $user->name,
            'email' => $user->email,
            'avatar' => $user->imageUrl,
        ]);
    }
1172767
private function createAdmin(): void
    {
        $this->connection->beginTransaction();
        try {
            $this->userService->createUser(
                [
                    'email' => $this->email,
                    'password' => $this->password,
                    'is_active' => BoolEnum::yes()->id(),
                    'activated_at' => Carbon::now()->toDateTimeString(),
                ],
                [
                    'first_name' => 'Super',
                    'last_name' => 'Admin',
                    // TODO set admin default photo
                ],
                [
                    $this->roleRepository->getRoleSuperAdminId(),
                    $this->roleRepository->getRoleUserId()
                ]
            );
        } catch (\Throwable $exception) {
            $this->connection->rollBack();

            report($exception);

            $this->info('error:');
            $this->error($exception->getMessage());

            exit;
        }

        $this->connection->commit();
    }
1154597
private function complete_change_owner() {
            $this->_logger->entrance();

            $site_result = $this->get_api_site_scope( true )->get();
            $site        = new FS_Site( $site_result );
            $this->_site = $site;

            $user     = new FS_User();
            $user->id = fs_request_get( 'user_id' );

            // Validate install's user and given user.
            if ( $user->id != $this->_site->user_id ) {
                return false;
            }

            $user->public_key = fs_request_get( 'user_public_key' );
            $user->secret_key = fs_request_get( 'user_secret_key' );

            // Fetch new user information.
            $this->_user = $user;
            $user_result = $this->get_api_user_scope( true )->get();
            $user        = new FS_User( $user_result );
            $this->_user = $user;

            $this->_set_account( $user, $site );

            return true;
        }
302609
protected function updateInheritancePermissions()
    {
        foreach ($this->inheritancePermissions() as $role => $items) {
            foreach ($items as $item) {
                $this->authManager
                    ->addChild(RbacFactory::Role($role), RbacFactory::Permission($item));

                echo sprintf('    > role `%s` inherited permission `%s`.', $role, $item) . PHP_EOL;
            }
        }
    }
324961
public function actionRun()
    {
        Yii::$app->session->set(Installation::SESSION_KEY, 0);

        if ($this->module->userComponent !== true && empty($this->module->adminId)) {
            $this->warning(Yii::t('podium/flash', "{userComponent} is set to custom but no administrator ID has been set with {adminId} parameter. Administrator privileges will not be set.", [
                'userComponent' => '$userComponent',
                'adminId' => '$adminId'
            ]));
        }
        return $this->render('run', ['version' => $this->module->version]);
    }
776024
public function createUserMenu()
    {
        $menu = $this->factory->createItem('root');

        if ($this->accountEnabled) {
            if (null !== $token = $this->tokenStorage->getToken()) {
                if ($this->authorization->isGranted('IS_AUTHENTICATED_FULLY') || $this->authorization->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
                    /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
                    $user = $token->getUser();
                    $item = $menu->addChild($user->getEmail(), ['uri' => '#']);
                    $item->addChild('ekyna_user.account.menu.my_profile', ['route' => 'fos_user_profile_show']);
                    if ($this->authorization->isGranted('ROLE_ADMIN')) {
                        $item->addChild('ekyna_user.account.menu.backend', ['route' => 'ekyna_admin']);
                    }
                    $item->addChild('ekyna_user.account.menu.logout', ['route' => 'fos_user_security_logout']);
                    return $menu;
                }
            }
            $menu->addChild('ekyna_user.account.menu.login', ['route' => 'fos_user_security_login']);
        }

        return $menu;
    }
550355
function signIn()
    {
        if ( (null === $identity = $this->identity) || !$identity->isFulfilled() )
            throw new \Exception('Identity not exists or not fullfilled');

        $identity = serialize($identity);
        $this->_storage()->set(self::STORAGE_IDENTITY_KEY , $identity);
        return $this;
    }
972809
protected function setupAdministrator()
    {
        $question = new ConfirmationQuestion('Would you like to create default administrator user (Recommended)? [y/n] ', true);
        if (!$this->helper->ask($this->input, $this->output, $question)) {
            return;
        }

        $this->runCommand('avoo:user:create');
    }
787769
public function registerUser()
    {
        // Create the new user
        $user = $this->user->create($this->getUserFromRequest());

        if (! $user) {
            return $user;
        }

        // Fire the registering event.
        event(new UserRegistering($user));

        // Add the extra details needed to finish them.
        // Add the user details.
        $this->userDetails->create($this->getUserDetailsFromRequest($user));

        // Assign the user to the default group
        $user->assignRole(config('jumpgate.users.default_role'));

        // If we do not require activation, set the user as active.
        if (! config('jumpgate.users.require_email_activation')) {
            $user->setStatus(Status::ACTIVE);
        }

        // Fire the registered event.
        event(new UserRegistered($user));

        return $user;
    }
1374929
public function createUser()
    {
        $data['name']     = $this->ask('Administrator name');
        $data['email']    = $this->ask('Administrator email');
        $data['password'] = bcrypt($this->secret('Administrator password'));
        $data['role_id']  = 1;
        User::create($data);
        $this->info('User has been created');
    }
631066
public function installUsers()
    {
        $this->_userService = new erdiko\users\models\User();

        $results = array(
            "successes" => array(),
            "failures"  => array(),
        );

        foreach($this->_usersArray as $user) {

            // get role ID from the name
            $user["role"] = $this->_getRole($user["role"])->getId();

            // create the user
            $createResult = (boolean)$this->_userService->createUser($user);

            unset($user["password"]);

            if(true !== $createResult) {
                $results["failures"][] = $user;
            } else {
                $results["successes"][] = $user;
            }
        }

        return $results;
    }
450041
public function authenticate()
    {
        /* @var $user \Grid\User\Model\User\Structure */
        $user = $this->getModel()
                     ->findByEmail( $this->email );

        if ( empty( $user ) )
        {
            return new Result( Result::FAILURE_IDENTITY_NOT_FOUND, null );
        }

        if ( ! $user->isActive() ||
             ! $user->verifyPassword( $this->password, true ) )
        {
            return new Result( Result::FAILURE_CREDENTIAL_INVALID, null );
        }

        return new Result( Result::SUCCESS, $user );
    }
1214309
public function getUser()
    {
        if ($user = $this->provider->parseToken()->toUser()) {
            return ($field = $this->field) ? (string) $user->{$field} : $this->provider->getIdentifier();
        }
    }