public function process() { if ($this->validate()) { $this->_user->passhash = User::hashPassword($this->password); return $this->_user->save(); } return false; }
/** * Creates admin user */ public function actionCreate() { $user = new User(); $user->name = $this->name; $user->login = $this->login; $user->email = $this->email; $user->is_active = in_array($this->active, ['yes', 'y', '1']) ? 1 : 0; $user->is_super_admin = in_array($this->superadmin, ['yes', 'y', '1']) ? 1 : 0; $user->passhash = User::hashPassword($this->password); if ($user->save()) { return self::EXIT_CODE_NORMAL; } else { $this->stderr("Errors: " . Json::encode($user->getErrors())); return self::EXIT_CODE_ERROR; } }