Saving new user.

@param  \Orchestra\Model\User  $user
@param  array  $input
@param  string  $password

@return void
774654
protected function saving(Eloquent $user, array $input, $password)
    {
        $user->setAttribute('email', $input['email']);
        $user->setAttribute('fullname', $input['fullname']);
        $user->setAttribute('password', $password);

        $this->fireEvent('creating', [$user]);
        $this->fireEvent('saving', [$user]);

        $user->saveOrFail();

        $this->fireEvent('created', [$user]);
        $this->fireEvent('saved', [$user]);
    }
101851
public function addUser($user, $password)
    {
        $params = [
            'name' => $user,
            'password' => $password,
        ];

        $body = $this->request(self::URI_AUTH_USER_ADD, $params);

        return $body;
    }
1025861
public function changePassword(User $user, Request $request)
    {
        $user->password = Hash::make($request->get('password'));
        $user->save();

        Alert::info(__('User was saved'));

        return back();
    }
473533
protected function resetPassword($user, $password)
    {
        $user->forceFill([
            'password' => bcrypt($password),
            'remember_token' => Str::random(60),
        ])->save();
    }
233292
public function setUser(User $user): void
    {
        $this->user = $user;
        $this->user->setAcl($this);

        $userRole = $this->user->getRole();
        if ($userRole != null && !empty($this->rules)) {
            foreach ($this->rules as $role => $rules) {
                if ($userRole == $role) {
                    foreach ($rules as $uri => $rules) {
                        $this->user->setPermissionsOf($uri, (array) explode(',', $rules) /* 'read,write' etc. */);
                    }
                    break;
                }
            }
        }
    }
1079661
public function setUserInfo($user = null, $password = null)
	{
		$this->user = $user;
		$this->pass = $password;
		return $this;
	}
106509
public function withUserInfo($user, $password = null)
    {
        $this->user = $user;
        $this->password = $password;

        return $this;
    }
11771
public function edit_load_user_data($user) {
        if ($this->data !== null) {
            $user->{$this->inputname} = $this->data;
        }
    }
717300
public function setUser(\Concrete\Core\Entity\User\User $user)
    {
        $this->author = $user;
        $this->save();
    }
326669
protected function resetPassword($user, $password)
    {
        $user->password = (new Hasher())->make($password);

        Person::save($user);
        auth()->login($user);
    }
972897
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        parent::initialize($input, $output);
        $this->permissionResolver->setCurrentUserReference(
            $this->userService->loadUserByLogin($input->getOption('user'))
        );
    }
771261
public function login(User $user, $password)
    {
        if ($user->isPasswordValid($password)) {
            $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
            $this->tokenStorage->setToken($token);
            $user->setLastLogin(new \DateTime());
            $this->save($user);

            return true;
        }

        return false;
    }
493066
private function processChangePassword(User $user, $password, $confirmPassword)
    {
        if (empty($password)) {
            return Errors::PASSWORD_INVALID;
        }

        if ($password !== $confirmPassword) {
            return Errors::CONFIRM_PASSWORD_INVALID;
        }

        /** @var UserMapper $mapper */
        $mapper = MapperFactory::getUserMapper();

        $user->setPassword($password);
        $mapper->update($user);

        // Now login this user.
        return $this->module->login($this->request, $user);
    }
695985
protected function editor(User $user)
    {
        // store props
        $oldProps = new UserUpdater($user);
        $newProps = $this->getNewValues($user);

        // confirm
        $ln = <<<EOL
Summary
-------
Username: "{$newProps->getUsername()}"
Email:    "{$newProps->getEmail()}"
Password: "{$newProps->getPassword()}"
EOL;
        $this->logger->block($ln);

        // check changes
        $changedValues = $oldProps->getChanged($newProps);
        if (empty($changedValues)) {
            $this->logger->note('Nothing changed, exiting.');

            return;
        }
        // persist
        if ($persist = $this->ask(new ConfirmationQuestion('Confirm user update?'))) {
            $this->userEditor->updateUser($user, $newProps);
            $this->logger->success('User updated!');
        }
        // send mail
        if ($persist) {
            $dontSend = 'Don\'t send';
            $emailChoices = [$dontSend, $oldProps->getEmail()];
            if (isset($changedValues['email'])) {
                $emailChoices[] = $changedValues['email'];
            }
            $to = $this->ask(new ChoiceQuestion('Send notification to', $emailChoices));
            if ($to !== $dontSend) {
                $this->sendNotification($to, $changedValues);
            }
        }
    }
1036740
public function sendGeneratedPassword(User $user, $password)
    {
        return $this->sendMessage(
            $user->email,
            $this->getNewPasswordSubject(),
            'new_password',
            ['user' => $user, 'password' => $password, 'module' => $this->module]
        );
    }
1260098
public function changePassword(User $user)
    {
        if ($user->isGuest()) {
            Throw new UserException('Cannot change password of a guest.');
        }

        if (empty($user->getPassword())) {
            Throw new UserException('Cannot change an empty password');
        }

        $hashgen = new HashGenerator($user->getPassword());
        $hashgen->setSalt($this->salt);
        $password = $hashgen->generate();

        // Check the old password
        $this->db->qb([
            'table' => $this->table,
            'method' => 'UPDATE',
            'fields' => 'password',
            'filter' => 'id_user=:id_user',
            'params' => [
                ':id_user' => $user->getId(),
                ':password' => $password
            ]
        ], true);

        $user->setPassword($password);
    }
1133015
public function actionValidatePassword($user, $password)
    {
        $user = $this->getUser($user);
        $result = $user->validatePassword($password);
        if ($result) {
            echo "Correct.\n";
        } else {
            echo "Incorrect.\n";
        }
        return static::EXIT_CODE_NORMAL;
    }