/** * Create a new user * * @route crew/users/new * @param string $userId */ public function createUser(string $userId = '') { $userId = (int) $userId; $user = $this->account->getUserAccount($userId, true); $post = $this->post(new NewUserFilter()); if ($post) { if (!empty($post['preferences'])) { if (\is_string($post['preferences'])) { $post['preferences'] = \json_decode($post['preferences'], true); } } else { $post['preferences'] = []; } $userId = $this->account->createUser($post); if ($userId) { $this->account->editUserCustomFields($userId, $post['custom_fields'] ?? '[]'); \Airship\redirect($this->airship_cabin_prefix . '/crew/users'); } } $this->lens('crew/user_new', ['active_link' => 'bridge-link-admin-crew-users', 'user' => $user, 'groups' => $this->account->getGroupTree()]); }
/** * Process a user account registration request * * @param array $post */ protected function processBoard(array $post = []) { if (empty($post['username']) || empty($post['passphrase'])) { $this->lens('board', ['post_response' => ['message' => \__('Please fill out the form entirely'), 'status' => 'error']]); } if ($this->acct->isUsernameTaken($post['username'])) { $this->lens('board', ['post_response' => ['message' => \__('Username is not available'), 'status' => 'error']]); } if ($this->acct->isPasswordWeak($post)) { $this->lens('board', ['post_response' => ['message' => \__('Supplied password is too weak.'), 'status' => 'error']]); } $userID = $this->acct->createUser($post); $_SESSION['userid'] = (int) $userID; \Airship\redirect($this->airship_cabin_prefix); }