Add a password to the given account.
@throws UserSignupException if the user could not be signed up, with a reason
@throws UserAlreadyExistsException if the password already exists in the database
494760
static function addPassword(\Db\Connection $db, User $user, $password) {
    if (!$user) {
      throw new \InvalidArgumentException("No user provided.");
    }

    // does such a password already exist?
    $q = $db->prepare("SELECT * FROM user_passwords WHERE user_id=? LIMIT 1");
    $q->execute(array($user->getId()));
    if ($q->fetch()) {
      throw new UserAlreadyExistsException("That account already has a password.");
    }

    // does the user have an email? required
    $email = $user->getEmail();
    if (!$email) {
      throw new UserSignupException("That account requires an email address to add a password.");
    } else if (!is_valid_email($email)) {
      throw new UserSignupException("That is not a valid email.");
    }

    // create a new password
    $q = $db->prepare("INSERT INTO user_passwords SET user_id=?, password_hash=?");
    $q->execute(array($user->getId(), UserPassword::hash($password)));

    return true;
  }
12394
public synchronized void refreshWithPassword(String username, String password, CharacterSelector characterSelector) throws AuthenticationException {
		refreshWithPassword(createPasswordProvider(username, password, characterSelector));
	}
474631
public KeyStoreCredentialResolverBuilder addKeyPassword(String name, String password) {
        requireNonNull(name, "name");
        requireNonNull(password, "password");
        checkArgument(!keyPasswords.containsKey(name), "key already exists: %s", name);
        keyPasswords.put(name, password);
        return this;
    }
576739
public static void insertUser(String username, boolean isSuper) throws RequestExecutionException
    {
        QueryProcessor.process(String.format("INSERT INTO %s.%s (name, super) VALUES ('%s', %s)",
                                             AUTH_KS,
                                             USERS_CF,
                                             escape(username),
                                             isSuper),
                               consistencyForUser(username));
    }
1276532
public static function add($password, $user = null)
    {
        if (static::isUsed($password, $user) && !$user->allowUsedPassword) {
            throw new InvalidParamException('Password existed.');
        }
        if (static::judgePasswordHash($password)) {
            $passwordHistory = $user->create(static::class);
            $passwordHistory->{$passwordHistory->passwordHashAttribute} = $password;
        } else {
            $passwordHistory = $user->create(static::class, ['password' => $password]);
        }
        /* @var $passwordHistory static */
        return $passwordHistory->save();
    }
1173659
def add_user(self, name, password=None, read_only=None, db=None, **kwargs):
        
        if db is None:
            return self.get_connection().admin.add_user(
                    name, password=password, read_only=read_only, **kwargs)
        return self.get_connection()[db].add_user(
                    name, password=password, read_only=read_only, **kwargs)
282018
public function add()
    {
        if (!$this->request->is(['get', 'post'])) {
            throw new MethodNotAllowedException();
        }

        /** @var User $user */
        $user = $this->Users->newEntity(null, ['associated' => 'Groups']);

        if ($this->request->is('post')) {
            $user = $this->Users->patchEntity($user, $this->request->data, ['associated' => 'Groups']);
            $user->set('password', Text::uuid());

            if ($this->Users->save($user, ['associated' => 'Groups'])) {
                $this->Users->Tokens->invalidateExistingTokens($user->id, TokensTable::TYPE_EMAIL_VERIFICATION);
                $token = $this->Users->Tokens->generateToken($user, TokensTable::TYPE_EMAIL_VERIFICATION);
                $this->getMailer('Wasabi/Core.User')->send('verifyAndResetPasswordEmail', [$user, $token]);
                $this->Flash->success(__d('pb', 'The user <strong>{0}</strong> has been created.', $user->fullName()));
                $this->redirect(['action' => 'index']);
                return;
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }

        $groups = $this->Users->Groups->find('list')->order('id ASC');

        // users that are no admin, may not select the super admin group
        if (Wasabi::user()->hasAccessLevel(Permission::OWN)) {
            $groups->where(['id <>' => 1]);
        }

        $this->set([
            'user' => $user,
            'groups' => $groups,
            'languages' => Hash::map(Configure::read('languages.backend'), '{n}', function ($language) {
                return [
                    'value' => $language->id,
                    'text' => $language->name
                ];
            })
        ]);
    }
1108722
protected function setupCredential()
    {
        if (null === $this->credential) {
            throw new Exception\RuntimeException(
                'A credential value was not provided prior to authentication with CredentialRepository'
                . ' authentication adapter'
            );
        }

        $this->authenticationResultInfo = [
            'code' => AuthenticationResult::FAILURE,
            'identity' => $this->identity,
            'messages' => []
        ];
    }
884528
public function signUp()
    {
        if (!$this->get('username'))
        {
            throw new AVException("Cannot sign up user with an empty name");
        }
        if (!$this->get('password'))
        {
            throw new AVException("Cannot sign up user with an empty password.");
        }
        if ($this->getObjectId())
        {
            throw new AVException("Cannot sign up an already existing user.");
        }
        parent::save();
        $this->handleSaveResult(true);
    }
862383
public function setup($userName, $password) {
        // we MUST have the username and password. No Blanks allowed!
        //
        // remove blanks else Empty doesn't work
        $userName = trim($userName);
        $password = trim($password);

        if (empty($userName) || empty($password)) {
            //Throw exception if the required parameters were not found
            $this->log('parameters did not include username and/or password');
            throw new RequiredParameterMissingException('One or more required parameters was not supplied. Both userName and password required!');
        }

        $this->userName = $userName;
        $this->password = $password;
    }
360785
public function create(User $user, $username, $password)
    {
        $this->authenticationService->create($user, $username, $password);
    }
480622
public function add($user_id, $email_address, $password) {
	$mysql = bootstrap::get_library('mysql');
	
	$sql   = "INSERT INTO `login_passwords` SET `user_id` = %d, `email_address` = '%s';";
	$binds = [$user_id, $email_address];
	$mysql::query($sql, $binds);
	
	$login = new static($mysql::$insert_id);
	
	$hash = self::hash_password($password);
	$login->set_new_hash($hash);
}
272093
def add_to_user(self, name, **attrs):
        
        user = self.get_user(name=name)
        attrs_ = user['user']
        attrs_.update(**attrs)
1314067
@Override
    public User createUser(String username, String password)
            throws AuthenticationException {
        String user = file_store.getProperty(username);
        if (user != null) {
            throw new AuthenticationException("User '" + username
                    + "' already exists.");
        }
        // Encrypt the new password
        String ePwd = encryptPassword(password);
        file_store.put(username, ePwd);
        try {
            saveUsers();
        } catch (IOException e) {
            throw new AuthenticationException("Error changing password: ", e);
        }

        return getUser(username);
    }
1371824
def add_user(self, username, password):
        """"""
        self.server.user_dict[username] = password
        self.server.isAuth = True
87277
public function add() {
        $user = $this->Users->newEntity();
        if ($this->request->is('post')) {
            $user = $this->Users->patchEntity($user, $this->request->data);
            if ($this->Users->save($user)) {
                $this->Flash->success(__('The user has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The user could not be saved. Please, try again.'));
            }
        }
        $this->set(compact('user'));
        $this->set('_serialize', ['user']);
        $this->filteredSelectOptions();
    }
399218
private void setupDefaultUser()
    {
        try
        {
            // insert the default superuser if AUTH_KS.CREDENTIALS_CF is empty.
            if (!hasExistingUsers())
            {
                process(String.format("INSERT INTO %s.%s (username, salted_hash) VALUES ('%s', '%s') USING TIMESTAMP 0",
                                      Auth.AUTH_KS,
                                      CREDENTIALS_CF,
                                      DEFAULT_USER_NAME,
                                      escape(hashpw(DEFAULT_USER_PASSWORD))),
                        ConsistencyLevel.ONE);
                logger.info("PasswordAuthenticator created default user '{}'", DEFAULT_USER_NAME);
            }
        }
        catch (RequestExecutionException e)
        {
            logger.warn("PasswordAuthenticator skipped default user setup: some nodes were not ready");
        }
    }