Adds a new User to the provider.

@throws \LogicException
495105
public function createUser(UserInterface $user)
    {
        if (isset($this->users[strtolower($user->getUsername())])) {
            throw new \LogicException('Another user with the same username already exists.');
        }

        $this->users[strtolower($user->getUsername())] = $user;
    }
1090294
public function Add() {
      $this->Permission('Garden.Users.Add');
      
      // Page setup
      $this->AddJsFile('user.js');
      $this->Title(T('Add User'));
      $this->AddSideMenu('dashboard/user');
      
      $RoleModel = new RoleModel();
      $AllRoles = $RoleModel->GetArray();
      
      // By default, people with access here can freely assign all roles
      $this->RoleData = $AllRoles;
      
      $UserModel = new UserModel();
      $this->User = FALSE;

      // Set the model on the form.
      $this->Form->SetModel($UserModel);
      
      try {
         // These are all the 'effective' roles for this add action. This list can
         // be trimmed down from the real list to allow subsets of roles to be edited.
         $this->EventArguments['RoleData'] = &$this->RoleData;

         $this->FireEvent("BeforeUserAdd");

         if ($this->Form->AuthenticatedPostBack()) {

            // These are the new roles the creating user wishes to apply to the target
            // user, adjusted for his ability to affect those roles
            $RequestedRoles = $this->Form->GetFormValue('RoleID');

            if (!is_array($RequestedRoles)) $RequestedRoles = array();
            $RequestedRoles = array_flip($RequestedRoles);
            $UserNewRoles = array_intersect_key($this->RoleData, $RequestedRoles);

            // Put the data back into the forum object as if the user had submitted 
            // this themselves
            $this->Form->SetFormValue('RoleID', array_keys($UserNewRoles));

            $NewUserID = $this->Form->Save(array('SaveRoles' => TRUE, 'NoConfirmEmail' => TRUE));
            if ($NewUserID !== FALSE) {
               $Password = $this->Form->GetValue('Password', '');
               $UserModel->SendWelcomeEmail($NewUserID, $Password, 'Add');
               $this->InformMessage(T('The user has been created successfully'));
               $this->RedirectUrl = Url('dashboard/user');
            }

            $this->UserRoleData = $UserNewRoles;
         } else {
            // Set the default roles.
            $this->UserRoleData = C('Garden.Registration.DefaultRoles', array());
         }

      } catch (Exception $Ex) {
         $this->Form->AddError($Ex);
      }
      $this->Render();
   }
794717
public function add()
    {
        $user = $this->Users->newEntity();

        if ($this->request->is('post')) {
            $user = $this->Users->patchEntity($user, $this->request->getData());

            if ($this->Users->save($user)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('user'));
    }
804671
def add_user(self, user, **kwargs):
        """"""
        if isinstance(user, User):
            user = user['id']

        assert isinstance(user, six.string_types)

        endpoint = '{0}/{1}/users/{2}'.format(
            self.endpoint,
            self['id'],
            user,
        )
        result = self.request('PUT', endpoint=endpoint, query_params=kwargs)
        return result
1327236
public void addUser(PrincipalUser user) {
        SystemAssert.requireArgument(user != null, "Null user can not be added.");
        users.add(user);
    }
784172
public function refer()
    {
        if ($this->context == null) {
            throw new LogicException('Context must be set before refer to the service.');
        }

        if ($this->proxyFactory == null) {
            throw new LogicException('Proxy factory must be set before refer to the service.');
        }

        if ($this->clientFactory == null) {
            throw new LogicException('Client factory must be set before refer to the service.');
        }

        $identify = $this->config['id'] ?? $this->config['interface'] ?? null;

        $this->container->instance($identify, $this->getProxy());
    }
889009
protected function createLock()
	{
		$user = $this->getCurrentUser();

		if (! $user) {
			throw new \LogicException('There is no user to attach the lock.');
		}
		
		$localization = $this->getPageLocalization();

		$currentRevision = $this->getAuditReader()
				->getCurrentRevision($localization::CN(), $localization->getId());

		$lock = new EditLock();

		$lock->setUserName($user->getUsername());
		$lock->setLocalizationRevision($currentRevision);

		$entityManager = $this->getEntityManager();

		$entityManager->persist($lock);
		$entityManager->flush();

		return $lock;
	}
1194127
public function addme()
    {
        // user exists ?
        $oUser = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
        if ($oUser->load(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('uid'))) {
            $sConfirmCode = md5($oUser->oxuser__oxusername->value . $oUser->oxuser__oxpasssalt->value);
            // is confirm code ok?
            if (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('confirm') == $sConfirmCode) {
                $oUser->getNewsSubscription()->setOptInStatus(1);
                $oUser->addToGroup('oxidnewsletter');
                $this->_iNewsletterStatus = 2;
            }
        }
    }
513595
public function addUser($postValues)
    {
        $userObj = UserFactory::createUserFromPostValues($postValues);

        $doesItExist = $this->getUserBySlug($userObj->slug);
        if (!empty($doesItExist)) {
            throw new \Exception('Trying to add username that already exists.');
        }
        $users = $this->repository->users;
        $users[] = $userObj;
        $this->repository->users = $users;
        $this->save();
    }
421773
private function createUser(SamlSpResponseToken $token)
    {
        if (null === $this->userCreator) {
            return null;
        }

        $user = $this->userCreator->createUser($token->getResponse());

        if ($user && false === $user instanceof UserInterface) {
            throw new \LogicException('User creator must return instance of UserInterface or null');
        }

        return $user;
    }
158140
public function add() {		
        
        $site = $this->SiteUser->Site->findByAlias(MtSites::getSiteName() );
        $this->request->data['Site']['id'] = $site['Site']['id'];
		
		if ( $this->request->is('post') ) {	
            
			$this->request->data[$this->modelClass]['tos'] = true;
			$this->request->data[$this->modelClass]['email_verified'] = true;
			//save new user
			if ($this->SiteUser->User->add($this->request->data)) {
				$this->Session->setFlash(__d('users', 'The User has been saved'));
				$this->redirect($this->referer());
			} else {
				$this->Session->setFlash(__d('users', 'The User couldn`t be saved'), 'Risto.flash_error');
			}
		}
		$roles = $this->SiteUser->User->Rol->find('list');
		$this->set('model', 'User');
		$this->set(compact( 'roles', 'site'));
	}
168501
public function boot()
    {
        if ($this->booted) {
            return;
        }

        if (!$this->name) {
            throw new \LogicException('Package: ' . get_class($this) . ' name property should not be empty.');
        }

        $this->getConfig();

        $this->registerProviders($this->getContainer());

        $this->registerListeners($this->getDispatcher());

        $this->registerMiddlewares();

        $this->booted = true;
    }
459005
public void addUser(User user){
		this.users.add(user);
		this.fireTableRowsInserted(this.users.size()-1, this.users.size()-1);
	}
259077
def AddUser(self, uid, username, active):
    '''
    '''
    user_path = '/org/freedesktop/login1/user/%i' % uid
    if user_path in mockobject.objects:
        raise dbus.exceptions.DBusException('User %i already exists' % uid,
                                            name=MOCK_IFACE + '.UserExists')

    self.AddObject(user_path,
                   'org.freedesktop.login1.User',
                   {
                       'Sessions': dbus.Array([], signature='(so)'),
                       'IdleHint': False,
                       'DefaultControlGroup': 'systemd:/user/' + username,
                       'Name': username,
                       'RuntimePath': '/run/user/%i' % uid,
                       'Service': '',
                       'State': (active and 'active' or 'online'),
                       'Display': ('', dbus.ObjectPath('/')),
                       'UID': dbus.UInt32(uid),
                       'GID': dbus.UInt32(uid),
                       'IdleSinceHint': dbus.UInt64(0),
                       'IdleSinceHintMonotonic': dbus.UInt64(0),
                       'Timestamp': dbus.UInt64(42),
                       'TimestampMonotonic': dbus.UInt64(42),
                   },
                   [
                       ('Kill', 's', '', ''),
                       ('Terminate', '', '', ''),
                   ])

    return user_path
746567
protected function wizardAddRole()
    {
        $this->validatePrompt('name', $this->text('Name'), 'user_role');
        $this->validatePromptList('permissions', $this->text('Permissions'), 'user_role');
        $this->validatePrompt('redirect', $this->text('Redirect'), 'user_role', '');
        $this->validatePrompt('status', $this->text('Status'), 'user_role', 0);
        $this->setSubmittedList('permissions');

        $this->validateComponent('user_role');
        $this->addRole();
    }
741981
public function add()
    {
        $this->loadModel('User.Roles');
        $role = $this->Roles->newEntity();

        if ($this->request->data()) {
            $role = $this->Roles->patchEntity($role, $this->request->data(), ['fieldList' => 'name']);
            if ($this->Roles->save($role)) {
                $this->Flash->success(__d('user', 'Role successfully created.'));
            } else {
                $this->Flash->danger(__d('user', 'Role could not be created.'));
            }
        }

        $this->title(__d('user', 'Define New Role'));
        $this->set(compact('role'));
        $this->Breadcrumb
            ->push('/admin/user/manage')
            ->push(__d('user', 'Roles'), ['plugin' => 'User', 'controller' => 'roles', 'action' => 'index'])
            ->push(__d('user', 'Add new role'), '');
    }
164080
protected function submitAddUser()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->setSubmittedJson('data');

        $this->validateComponent('user');
        $this->addUser();
    }